loongson/pypi/: unicodecsv-0.14.1 metadata and description

Homepage Simple index

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

author Jeremy Dunck
author_email jdunck@gmail.com
classifiers
  • Development Status :: 5 - Production/Stable
  • Intended Audience :: Developers
  • License :: OSI Approved :: BSD License
  • Natural Language :: English
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 3.3
  • Programming Language :: Python :: 3.4
  • Programming Language :: Python :: 3.5
  • Programming Language :: Python :: Implementation :: PyPy
  • Programming Language :: Python :: Implementation :: CPython
license BSD License
platform
  • UNKNOWN

Because this project isn't in the mirror_whitelist, no releases from root/pypi are included.

File Tox results History
unicodecsv-0.14.1-py3-none-any.whl
Size
11 KB
Type
Python Wheel
Python
3
  • Replaced 2 time(s)
  • Uploaded to loongson/pypi by loongson 2023-06-01 00:45:00
unicodecsv-0.14.1.tar.gz
Size
10 KB
Type
Source
  • Replaced 2 time(s)
  • Uploaded to loongson/pypi by loongson 2023-06-01 00:45:02

The unicodecsv is a drop-in replacement for Python 2.7’s csv module which supports unicode strings without a hassle. Supported versions are python 2.7, 3.3, 3.4, 3.5, and pypy 2.4.0.

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 as csv
>>> from io import BytesIO
>>> f = BytesIO()
>>> w = csv.writer(f, encoding='utf-8')
>>> _ = w.writerow((u'é', u'ñ'))
>>> _ = f.seek(0)
>>> r = csv.reader(f, encoding='utf-8')
>>> next(r) == [u'é', u'ñ']
True

Note that unicodecsv expects a bytestream, not unicode – so there’s no need to use codecs.open or similar wrappers. Plain open(…, ‘rb’) will do.

(Version 0.14.0 dropped support for python 2.6, but 0.14.1 added it back. See c0b7655248c4249 for the mistaken, breaking change.)