开发者

ignoring commas when reading from csv files in java

开发者 https://www.devze.com 2023-02-10 01:10 出处:网络
How do I st开发者_运维问答ore a string containing quotes or commas in to a csv file and retrieve it later without having my output split up?Best thing is to use api\'s meant for reading/writing csv\'s

How do I st开发者_运维问答ore a string containing quotes or commas in to a csv file and retrieve it later without having my output split up?


Best thing is to use api's meant for reading/writing csv's like opencsv

Can you recommend a Java library for reading (and possibly writing) CSV files?


Don't parse it yourself, use a library like this to do so: http://ostermiller.org/utils/CSV.html

This way, you don't need to worry about double quotes or commas in the string, etc.


Values are quoted, so any comma inside a pair of quotes is ignored.

Quotes are escaped by doubling. So any sequence of two quotes inside a value is replaced by a single quote.

You can read the details in RFC 4180.

0

精彩评论

暂无评论...
验证码 换一张
取 消