csv23
provides the unicode-based API of the Python 3 csv
module for
Python 2 and 3. Code that should run under both versions of Python can use it
to hide the bytes
vs. text
difference between 2 and 3 and stick to the
newer unicode-based interface.
csv23
works around for the following bugs in the stdlib csv
module:
- bpo-12178
- broken round-trip with
escapechar
if your data contains a literal escape character - bpo-31590
- broken round-trip with
escapechar
and embedded newlines under Python 2 (fixed in Python 3.4 but not backported): produce a warning
The package also provides some convenience functionality such as the
open_csv()
context manager for opening a CSV file in the right mode and
returning a csv.reader
or csv.writer
:
>>> import csv23
>>> with csv23.open_csv('spam.csv') as reader: # doctest: +SKIP
... for row in reader:
... print(', '.join(row))
Spam!, Spam!, Spam!'
Spam!, Lovely Spam!, Lovely Spam!'
It uses utf-8
as default encoding everywhere.
- GitHub: https://github.com/xflr6/csv23
- PyPI: https://pypi.org/project/csv23/
- Documentation: https://csv23.readthedocs.io
- Changelog: https://csv23.readthedocs.io/en/latest/changelog.html
- Issue Tracker: https://github.com/xflr6/csv23/issues
- Download: https://pypi.org/project/csv23/#files
This package runs under Python 2.7, and 3.4+, use pip to install:
$ pip install csv23
- https://docs.python.org/2/library/csv.html#examples (UnicodeReader, UnicodeWriter)
- https://agate.readthedocs.io/en/latest/api/csv.html
- https://pypi.org/project/backports.csv/
- https://pypi.org/project/csv342/
This package is distributed under the MIT license.