[issue36246] csv.writer lineterminator affects csv escaping

2019-03-15 Thread flow2k


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 to ingest it.

Closing the issue...

--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36246] csv.writer lineterminator affects csv escaping

2019-03-08 Thread Martin Panter

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 = 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: 
.

--
nosy: +martin.panter
resolution:  -> not a bug
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36246] csv.writer lineterminator affects csv escaping

2019-03-08 Thread flow2k


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: flow2k
priority: normal
severity: normal
status: open
title: csv.writer lineterminator affects csv escaping
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com