Writing a string with comma in one column of CSV file

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jan 16 17:38:05 EST 2022


On 17/01/22 4:18 am, Mats Wichmann wrote:
> the convention for Excel, which is usually the reason
> people are using csv, is you can enclose the entire comma-containing
> field in "quote marks" (afaik it must be double-quote).

And to include a double quote in a field, quote the field and
double the double-quote.

Another quirk is that Excel allows newlines in a quoted field,
which causes problems for naive parsers that split the input
into lines first and then analyse it into fields. (A particular
non-Python one I use professionally is guilty of this...)

-- 
Greg


More information about the Python-list mailing list