[New-bugs-announce] [issue22855] csv writer with blank lineterminator breaks quoting

Eric Haszlakiewicz report at bugs.python.org
Wed Nov 12 18:05:03 CET 2014


New submission from Eric Haszlakiewicz:

I'm trying to emit a single line of csv without any line terminators, but specifying lineterminator=None results in a "lineterminator must be set" error, and setting lineterminator='' results in lack of quotes around certain fields.

    with open("foo.csv", "wb") as csvfile:
        csvw = csv.writer(csvfile, quoting=csv.QUOTE_MINIMAL, lineterminator='')
        csvw.writerow(["col1","col2\ndata", "col3"])

I expected the contents of the file to be:
    col1,"col2
    data",col3

It should be possible to change the lineterminator without changing the quoting behavior.
At the very least, the documentation needs to explain better what logic is used to determine whether something gets quoted, and what affects that.

----------
components: Library (Lib)
messages: 231083
nosy: Eric.Haszlakiewicz
priority: normal
severity: normal
status: open
title: csv writer with blank lineterminator breaks quoting
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22855>
_______________________________________


More information about the New-bugs-announce mailing list