当前位置:网站首页>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)
边栏推荐
- 【kali-漏洞扫描】(2.1)Nessus下载安装(上)
- LeetCode_位数统计_中等_400.第 N 位数字
- Often forget HiFlow 】 【 check-in?Use tencent cloud scenario connector to remind you every day.
- 七夕快乐!
- 基于DMS的数仓智能运维服务,知多少?
- 剑指 Offer 07. 重建二叉树
- 火了十几年的零信任,为啥还不能落地
- Engineering Effectiveness Governance for Agile Delivery
- Markdown语法
- error: C1083: 无法打开包括文件: “QString”: No such error: ‘QDir‘ file not found
猜你喜欢
随机推荐
461. 汉明距离
敏捷交付的工程效能治理
Often forget HiFlow 】 【 check-in?Use tencent cloud scenario connector to remind you every day.
[kali-vulnerability scanning] (2.1) Nessus lifts IP restrictions, scans quickly without results, and plugins are deleted (middle)
C. Divan and bitwise operations
Transformer怎么入门?如何学习Transformer?
LitJson报错记录
4. Modular programming
详解虚拟机!京东大佬出品 HotSpot VM 源码剖析笔记(附完整源码)
XSS漏洞复现
E - Swap
False label aggregation
太香了! 阿里 Redis 速成笔记, 从头到尾全是精华!
gtk实现图片旋转
tkwebview2创作心得
if _name_ == “__main__“:NameError: name ‘_name_‘ is not defined
手动输入班级人数及成绩求总成绩和平均成绩?
解决npm -v查看npm版本出现npm WARN config global `--global`, `--local` are deprecated. Use `--location报错
XSS online shooting range---prompt
2022年强网杯rcefile wp