当前位置:网站首页>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)
边栏推荐
猜你喜欢
随机推荐
461. 汉明距离
基于data.table的tidyverse?
尚医通项目总结
《强化学习周刊》第56期:GraphIRL、REDEEMER & 眼科强化学习的潜在研究
检测和控制影子IT的五个步骤
LeetCode_Digit Statistics_Medium_400. Nth Digit
Security Fundamentals 8 --- XSS
测试2年6.5K,每天“911”,我的心酸经历只有我自己知道···
XSS线上靶场---Warmups
回忆三年浮沉
leetcode 461. Hamming Distance
Engineering Effectiveness Governance for Agile Delivery
What is the role and difference between buildscript and allprojects?
C. awoo‘s Favorite Problem--Educational Codeforces Round 130 (Rated for Div. 2)
gtk实现图片旋转
XSS练习---一次循环和两次循环问题
error: C1083: 无法打开包括文件: “QString”: No such error: ‘QDir‘ file not found
手动输入班级人数及成绩求总成绩和平均成绩?
XSS测试
glusterfs build and use









