4 ms·
> access through cat/grep/awk, and easily load into any programming language Until the CSV fields contain commas themselves. Even if fields are surrounded by "
by xtracto 5y ago
> access through cat/grep/awk, and easily load into any programming language
Until the CSV fields contain commas themselves. Even if fields are surrounded by "".
- megous 5y agoThen you just switch to a 3-line php script (fgetcsv() in a loop) and continue on... :)
- breck 5y agoSome people like me never generate CSVs like that. If someone sends me a CSV with quotes, I reject it and say "clean up your data". It's okay to say, "we're not going to allow escape characters in our CSV grammar. We're going to have a higher standard"
- danellis 5y agoNot everyone has the option of rejecting it, though. Sometimes you need that data and have no control over how it's being generated.
- the_only_law 5y agoI recall one of my old Phones could dump SMS messages as CSV. I wanted to be build and interface that would let me search through my messages. Turns out when you have data that contains both commas and quotes things get screwey real quick. You could have quoted data like: 123,ABC,”,””,456 Where ,” is column data. I think that standard method is to double quote the field, but the dump sure wasn’t doing that for me, plus what happens when the data is something like abc””,?
- deleted 5y ago[deleted]
- rendall 5y ago> 123,ABC,”,””,456 That is badly formatted CSV, assuming ” is a double-quote. Double-quote (") is how you escape commas, so the 3rd entry will make a parser barf, since there is no close quote. It should be 123,ABC,"","",456 > Turns out when you have data that contains both commas and quotes things get screwey real quick. Not really. It's pretty logical. If the entry has even one comma, put quotes around it. If it also has quotes, double each of them. Otherwise don't worry about it. > what happens when the data is something like abc””,? abc"", becomes "abc"""","