escape character / csv module

John Machin sjmachin at lexicon.net
Fri Jul 2 08:12:04 EDT 2010


On Jul 2, 6:04 am, MRAB <pyt... at mrabarnett.plus.com> wrote:


> The csv module imports from _csv, which suggests to me that there's code
> written in C which thinks that the "\x00" is a NUL terminator, so it's a
> bug, although it's very unusual to want to write characters like "\x00"
> to a CSV file, and I wouldn't be surprised if this is the first time
> it's been noticed! :-)

Don't be surprised, read the documentation (http://docs.python.org/
library/csv.html#module-csv):

"""Note

This version of the csv module doesn’t support Unicode input. Also,
there are currently some issues regarding ASCII NUL characters.
Accordingly, all input should be UTF-8 or printable ASCII to be safe;
see the examples in section Examples. These restrictions will be
removed in the future."""

The NUL/printable part of the note has been there since the module was
introduced in Python 2.3.0.







More information about the Python-list mailing list