简体   繁体   中英

Escape comma in a cell value while parsing a CSV file using Apach Common CSV parser in java

I'm working on a code where i have a large csv file that is being parsed by java program. I'm using Apache Commons Csv parser to parse that file in java program.

Problem: Whenever there is some cell in csv file that has value like Yes, I am a developer the CSV parser treats Yes as one column and I am a developer as different coulmn (ie it reads & treats the cell as two different columns while parsing which should not be done as it's a value within same cell)

When editing the file i found that whenever a csv file cell contains a comma in its value then that's cell value is interpreted as in double quotes.

Any help here in escaping the comma which is in cell value will be very helpful?

Thanks in advance!

Enclose the field in quotes, eg

field1_value,field2_value,"field 3,value",field4, etc...

Check here: Link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM