Page 1 of 1

Is there a way to include commas in CSV columns without brea

Posted: Thu Aug 21, 2014 8:11 am
by vinodkumar
Is there any way to put commas in csv file.

I've got a two column CSV with a name and a number. Some people's name use commas, for example "Joe Blow, CFA." This comma breaks the entire CSV format.
How to handle this type of cases?Any alternative is there? Please let me know.

Re: Is there a way to include commas in CSV columns without

Posted: Thu Aug 21, 2014 8:19 am
by Celauran
Moved because this has nothing to do with Linux.

Wrapping your columns in quotes should prevent problems caused by commas in your values. You could also use a different separator.

Re: Is there a way to include commas in CSV columns without

Posted: Fri Aug 22, 2014 10:24 am
by pickle
Re: escaping: The standardized practice is to escape double quotes with double-double quotes:

42,"Joe ""The Blowman"" Blow, CFA.",100.0

http://www.ietf.org/rfc/rfc4180.txt, search for "double quotes"

Re: Is there a way to include commas in CSV columns without

Posted: Fri Aug 22, 2014 12:31 pm
by requinix
If you're writing the CSV using PHP then use fputcsv, which will deal with the quote thing for you.

Re: Is there a way to include commas in CSV columns without

Posted: Fri Aug 29, 2014 8:07 am
by Tayla6
I am not sure if there is any way to use commas in a csv file.