csv module and None values

John Yeung gallium.arsenide at gmail.com
Tue Aug 25 06:43:57 CEST 2009


On Aug 24, 5:00 pm, Peter Otten <__pete... at web.de> wrote:
> If I understand you correctly the csv.writer already does
> what you want:
>
> >>> w.writerow([1,None,2])
> 1,,2
>
> just sequential commas, but that is the special treatment.
> Without it the None value would be converted to a string
> and the line would look like this one:
>
> 1,None,2

No, I think he means he is getting

>>> w.writerow([1,None,2])
1,"",2

He evidently wants to quote "all" strings, but doesn't want None to be
considered a string.

John



More information about the Python-list mailing list