Skip to main content
Help us improve Python packaging – donate today!

Python2's stdlib csv module is nice, but it doesn't support unicode. This module is a drop-in replacement which *does*.

Project Description

TL;DR: The unicodecsv is a drop-in replacement for Python 2’s csv module which supports unicode strings without a hassle.

More fully:

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[0], row[1]
é ñ

Release history Release notifications

History Node

0.14.1

History Node

0.14.0

History Node

0.13.0

History Node

0.12.0

History Node

0.11.2

History Node

0.11.1

History Node

0.11.0

History Node

0.9.4

History Node

0.9.3

History Node

0.9.0

This version
History Node

0.8.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
unicodecsv-0.8.0.tar.gz (2.2 kB) Copy SHA256 hash SHA256 Source None Nov 27, 2011
unicodecsv-0.9.0.tar.gz (7.5 kB) Copy SHA256 hash SHA256 Source None Dec 2, 2011

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page