[issue4847] csv fails when file is opened in binary mode

Antoine Pitrou report at bugs.python.org
Mon Mar 9 11:39:35 CET 2009


Antoine Pitrou <pitrou at free.fr> added the comment:

> Not good. It should preserve ALL characters in the field.

Please look at the doc for open() and io.TextIOWrapper. The `newline`
parameter defaults to None, which means universal newlines with newline
translation. Setting to '' (yes, the empty string) enables universal
newlines but disables newline translation (that it, it will split lines
on all of ['\n', '\r', '\r\n'], but will leave these newlines intact
rather than convert them to '\n').

However, I think csv should accept files opened in binary mode and be
able to deal with line endings itself. How am I supposed to know the
encoding of a CSV file? Surely Excel uses a defined, default encoding
when exporting to CSV... that knowledge should be embedded in the csv
module.

----------
message_count: 12.0 -> 13.0

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


More information about the Python-bugs-list mailing list