当前位置:网站首页>How to deal with commas in the content of the CSV file of the system operation and maintenance series
How to deal with commas in the content of the CSV file of the system operation and maintenance series
2022-08-03 21:17:00 【Lang Xiaolin】
Problem description:
The CSV file is comma-separated by default, but if the content contains commas, the separation will fail or the array subscript matching will be out of bounds.
Processing method:
(1) Regular expression
//(?=pattern)//Non-acquisition match, positive pre-check, match the search string at the beginning of any string matching pattern, the match does not need to be acquired for later use//(?:pattern) //Non-acquisition match, matches pattern but does not obtain the matching result, and does not store it for later use.This is useful when using the or character "(|)" to combine parts of a pattern.For example "industr(?:y|ies)" is a shorter expression than "industry|industries"//Split commas not enclosed by double quotesline.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)")
(2) Use a third-party jar
<dependency><groupId>com.opencsv</groupId><artifactId>opencsv</artifactId><version>4.4</version></dependency>
References:
https://blog.csdn.net/wls_2019/article/details/123225335 Special cases (comma) in reading and writing csv files
https://www.cnblogs.com/allen2333/p/9835654.html Regular Expression - (?!), (?, (?=)
https://blog.csdn.net/superbeyone/article/details/83624241 Java reads CSV file (CSVThe file data content contains comma processing)
边栏推荐
- 【使用 Pytorch 实现入门级的人工神经网络】
- AI首席架构师13-AICA-智能文档分析技术在行业场景中的应用
- idea2021配置svn报错Cannot run program “svn“ (in directory “xxx“):CreateProcess error=2,系统找不到指定的文件
- 9月1日起我国给予多哥等16国98%税目产品零关税待遇
- LeetCode_位数统计_中等_400.第 N 位数字
- 字节跳动软件测试岗,前两面过了,第三面HR天坑,结局透心凉...
- ValidationError: Progress Plugin Invalid Options
- StoneDB 开源社区月刊 | 202207期
- dataframe multi-level index replace index df.swaplevel(axis=1)
- glusterfs build and use
猜你喜欢
随机推荐
IDaaS 是什么?一文说清它的价值
LeetCode_Digit Statistics_Medium_400. Nth Digit
有趣的opencv-记录图片二值化和相似度实现
博士申请 | 美国明尼苏达大学葛畅教授招收隐私数据管理方向全奖博士/硕士/博后/访问学者...
Soft exam system analysts note experience sharing: theory of protracted war
Transformer怎么入门?如何学习Transformer?
XSS测试
关于shell脚本的一些思考
CheckBox列表项选中动画js特效
服务器安装redis
6. XML
C. awoo‘s Favorite Problem--Educational Codeforces Round 130 (Rated for Div. 2)
chart.js多条曲线图插件
伪标签汇总
3种圆形按钮悬浮和点击事件
TweenMax.js向日葵表情变化
Security Fundamentals 8 --- XSS
收藏-即时通讯(IM)开源项目OpenIM-功能手册
gtk实现图片旋转
shell编程基础