Python2's stdlib csv module is nice, but it doesn't support unicode. This module is a drop-in replacement which *does*.
The unicodecsv is a drop-in replacement for Python 2’s csv module which supports unicode strings without a hassle.
Python 2’s csv module doesn’t easily deal with unicode strings, leading to the dreaded “‘ascii’ codec can’t encode characters in position …” exception.
You can work around it by encoding everything just before calling write (or just after read), but why not add support to the serializer?
>>> import unicodecsv >>> from cStringIO import StringIO >>> f = StringIO() >>> w = unicodecsv.writer(f, encoding='utf-8') >>> w.writerow((u'é', u'ñ')) >>> f.seek(0) >>> r = unicodecsv.reader(f, encoding='utf-8') >>> row = r.next() >>> print row, row é ñ
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size unicodecsv-0.12.0.tar.gz (9.4 kB)||File type Source||Python version None||Upload date||Hashes View|