Skip to main content

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]
é ñ

Project details


Download files

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

Source Distributions

unicodecsv-0.9.0.tar.gz (7.5 kB view details)

Uploaded Source

unicodecsv-0.8.0.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file unicodecsv-0.9.0.tar.gz.

File metadata

  • Download URL: unicodecsv-0.9.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for unicodecsv-0.9.0.tar.gz
Algorithm Hash digest
SHA256 d2781d5f0fa8b2b295cc7405abe493a51894cbfa378c405b98d4849e09d5f406
MD5 83044c801fc761ccd5722bb63b5ed952
BLAKE2b-256 b87d632b582cc79829aa33870713c0085c4e2ef61fa872d62d2a55f6acc09dcf

See more details on using hashes here.

File details

Details for the file unicodecsv-0.8.0.tar.gz.

File metadata

  • Download URL: unicodecsv-0.8.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for unicodecsv-0.8.0.tar.gz
Algorithm Hash digest
SHA256 a87cab4295104a14d60ff3a3a9ed9462daa2807265aee4e56718d6f2c5406964
MD5 cbb245b7dbec736effd70fffe66543e0
BLAKE2b-256 cfbd6e9d5621a329f42f8554c65a0b1fa0cb13b48f2353bfbf02748f8bd282a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page