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

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
vinodkumar
Forum Newbie
Posts: 4
Joined: Thu May 29, 2014 12:15 am

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

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

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

Post 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"
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

If you're writing the CSV using PHP then use fputcsv, which will deal with the quote thing for you.
Tayla6
Forum Commoner
Posts: 26
Joined: Thu Oct 10, 2013 8:40 am
Location: Manchester
Contact:

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

Post by Tayla6 »

I am not sure if there is any way to use commas in a csv file.
Tayla the great
Post Reply