This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients flow2k, martin.panter
Date 2019-03-09.00:09:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552090175.29.0.572831505899.issue36246@roundup.psfhosted.org>
In-reply-to
Content
This is the result that I see:

>>> output = StringIO()
>>> csv.writer(output, lineterminator='\n').writerow(["Whoa!\rNewlines!"])
16
>>> output.getvalue()
'Whoa!\rNewlines!\n'

For comparison, this is the result with CRLF terminators (the default):

>>> output = StringIO()
>>> csv.writer(output, lineterminator='\r\n').writerow(["Whoa!\rNewlines!"])
19
>>> output.getvalue()
'"Whoa!\rNewlines!"\r\n'

Is it a problem that the line terminator determines whether the CR is quoted or not? I believe the default policy is “excel”, which happens to use QUOTE_MINIMAL. This behaviour is documented: <https://docs.python.org/3.7/library/csv.html#csv.QUOTE_MINIMAL>.
History
Date User Action Args
2019-03-09 00:09:35martin.pantersetrecipients: + martin.panter, flow2k
2019-03-09 00:09:35martin.pantersetmessageid: <1552090175.29.0.572831505899.issue36246@roundup.psfhosted.org>
2019-03-09 00:09:35martin.panterlinkissue36246 messages
2019-03-09 00:09:35martin.pantercreate