当前位置:网站首页>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)
边栏推荐
- 独立站卖家在哪些平台做社交媒体营销效果最好?
- XSS online shooting range---haozi
- 主板设计中:网络变压器与RJ45网口之间应该保持什么样的距离?
- XSS online shooting range---prompt
- How can a cloud server safely use local AD/LDAP?
- 《强化学习周刊》第56期:GraphIRL、REDEEMER & 眼科强化学习的潜在研究
- NAACL 2022 | 具有元重加权的鲁棒自增强命名实体识别技术
- dataframe multi-level index replace index df.swaplevel(axis=1)
- 回忆三年浮沉
- PyCharm function automatically add comments without parameters
猜你喜欢
Interesting opencv - record image binarization and similarity
模板字符串
基于DMS的数仓智能运维服务,知多少?
【kali-漏洞扫描】(2.1)Nessus下载安装(上)
nvm的使用 nodejs版本管理,解决用户名是汉字的问题
详解虚拟机!京东大佬出品 HotSpot VM 源码剖析笔记(附完整源码)
15 years experience in software architect summary: in the field of ML, tread beginners, five hole
3种圆形按钮悬浮和点击事件
史兴国对谈于佳宁:从经济模式到落地应用,Web3的中国之路怎么走?
How can a cloud server safely use local AD/LDAP?
随机推荐
Markdown语法
【kali-漏洞扫描】(2.1)Nessus解除IP限制、扫描快无结果、插件plugins被删除(中)
数据库定时备份winserver2012篇
关于GPIO你真的懂了吗?这篇文章都给你整理好了
PyCharm函数自动添加注释无参数问题
Several difficult problems in DDD
尚医通项目总结
Cesium 修改鼠标样式
C. awoo‘s Favorite Problem--Educational Codeforces Round 130 (Rated for Div. 2)
XSS练习---一次循环和两次循环问题
软考系统分析师备考经验分享:论持久战
在树莓派上搭建属于自己的网页(3)
LitJson报错记录
云图说丨初识华为云微服务引擎CSE
TweenMax.js向日葵表情变化
ES6--residual parameters
shell编程基础
Android build error: Plugin with id ‘kotlin-android‘ not found.
系统运维系列 之CSV文件读取时内容中包含逗号的处理方法
C. Fishingprince Plays With Array--Codeforces Global Round 21