1

How do I store a string containing quotes or commas in to a csv file and retrieve it later without having my output split up?

1

3 Answers 3

3

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?

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.