4 ms·
Why not use the non-printing char as the comma instead of the record separator. 1. Replace all the commas in the text with the unique non-printing char before
by gwu78 13y ago
Why not use the non-printing char as the comma instead of the record separator.
1. Replace all the commas in the text with the unique non-printing char before converting to CSV.
2. Convert this char back to a comma when processing the CSV for output to be read by humans.
Because commas in text are usually followed by a space, the CSV may still even be readable when using the non-printing char.
I must admit I've never understood why others view CSV as so troublesome vis-a-vis other popular formats.
in: sed 's/,/%2c/g'
out: sed 's/%2c/,/g'
I guess I need someone to give me a really hairy dataset for me to understand the depth of the problem with CSV.
Meanwhile, I love CSV for its simplicity.
- dbro 13y agothat's exactly what https://github.com/dbro/csvquote https://github.com/dbro/csvquote does for commas and newlines both.
- gwu78 13y agoWhy use this instead of sed, awk, flex, lua, etc.? sed does the job and on almost all UNIX clones it never needs to be installed. Because it's already there.