Don't use CSV use DSV
Created:
This blogpost “CSVs Are Kinda Bad. DSVs Are Kinda Good.” explains why you may not want to export tabular data using CSV format.
I use field separator (FS) for exporting markdown from my tohray blog software for the same reasons.
Simon Willison commented on lobste.rs saying how you can use the standard Python CSV module to export safely , if you can’t use field separator
If you’re using the Python CSV module the easier way to get relatively sensitive escaping to work is to use the confusingly named “excel” dialect - which uses double quotes around strings that contain commas and correctly escapes those double quotes.
csv.writer(fp, dialect=“excel”).writerows(…)
Or use “excel_tab” for correctly escaped TSV.
I have been using CSV for a long time, and I find it quite handy. The Python CSV module is underrated because people often use pandas to do similar stuff on CSV, which I think is an overkill.