flow2k added the comment:
Okay, thanks for pointing to the doc. I did not expect the line termination to
affect escaping, but I can see why these may be related.
Per your comment, I've added quoting=csv.QUOTE_NONNUMERIC. Instead of Excel, I
am using Gdocs, and this escaping enables Gsheets
Martin Panter added the comment:
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 =
New submission from flow2k :
output = io.StringIO()
csvData = [1, 2, 'a', 'He said "what do you mean?"', "Whoa!\rNewlines!"]
writer = csv.writer(output,lineterminator='\n')
writer.writerow(csvData)
print(repr(output.getvalue())) #does not escape \r as expected
--
messages: 337537
nosy: