CSV module and UNICODE

skip at pobox.com skip at pobox.com
Thu Feb 23 21:39:53 EST 2006


    Rudy> I'm having problems writing unicode to a csv file.
    Rudy> I use the following code:
    ...

Have you tried the example UnicodeReader and UnicodeWriter classes in the
module documentation:

    http://www.python.org/dev/doc/devel/lib/node631.html

While the csv module is 8-bit clean it knows nothing about Unicode, so your
Unicode data has to be encoded before it hits the csv module code.  Your
code is expecting the Unicode to go through the csv module and be encoded to
utf-8 downstream in the by the eventual file object.

If there are people reading this who would like to tackle something for
Python 2.5, I am sure a patch that Unicodifies the csv module would be
welcome.

Skip



More information about the Python-list mailing list