csv23
Python 2/3 unicode CSV compatibility layer
What it is and what it does
csv23 bridges the Python 2/3 divide for CSV handling by exposing the Python 3 csv module API (which uses unicode strings) to both Python 2.7 and Python 3 code. The core problem it solves is that Python 2's csv module works with byte strings while Python 3's works with unicode, making it difficult to write CSV code that runs on both versions. csv23 hides this difference and defaults to UTF-8 encoding throughout.
Beyond basic compatibility, it provides convenience utilities like open_csv() context managers for simpler file handling, and on Python 3 it adds read_csv() and write_csv() functions that work with file-like objects (useful for reading/writing CSV data from binary streams). It also includes workarounds for specific stdlib CSV bugs related to escape characters and embedded newlines.
Use it for:
- Writing CSV parsing/writing code that must run unchanged on both Python 2.7 and Python 3 without conditional logic.
- Reading or writing CSV data directly to binary streams without intermediate disk writes.
- Calculating checksums over CSV output by piping to hashlib objects without writing to disk.
- Transparently handling compressed CSV files (.bz2, .gz, .xz) with the autocompress option.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python 3-style unicode CSV API that works consistently across Python 2.7 and Python 3, with UTF-8 as the default encoding and workarounds for stdlib CSV bugs.
Yes, if you maintain Python 2.7 code or need to support both Python 2 and 3 in the same codebase. The package is stable, has no known vulnerabilities, and low install friction. However, if you are writing new code for Python 3 only, the standard library csv module is sufficient—install this only if cross-version compatibility is a real requirement.
Install
csv23 on PyPI
pip
pip install csv23uv
uv add csv23poetry
poetry add csv23Installing csv23
Before you install
Low friction: pure Python wheel with a single mock dependency. Repository is active with recent commits (last commit 2026-07-06), though the latest release was 2022-06-12, suggesting the package is stable rather than actively developed.
License in practice
MIT license (permissive) means you can use this freely in commercial and open-source projects with minimal restrictions—just include the license notice.
Quickstart
pip install csv23
import csv23
with csv23.open_csv('data.csv') as reader:
for row in reader:
print(row)
Verify before relying
- Whether the package is still maintained or in maintenance-only mode given the gap between last release (2022-06-12) and recent commits.
- Scope of the stdlib CSV bugs fixed (bpo-12178, bpo-31590) and whether they remain relevant in current Python versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — mock |
| Maintenance | actively maintained — 1,524 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 327,602/month — #7,567 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: csv23-0.3.4-py2.py3-none-any.whl
Keywords: unicode, csv, reader, writer
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
backports.csvProvides Python 3's csv module API for Python…
unclear · top 15,000 on PyPI
clevercsvCleverCSV detects CSV file dialects…
permissive · top 15,000 on PyPI
django-queryset-csvExports Django QuerySet data to CSV format with…
copyleft · top 15,000 on PyPI
pyorcPyORC reads and writes Apache ORC files using…
permissive · top 15,000 on PyPI
unicodecsvDrop-in replacement for Python 2.7's csv module…
permissive · top 5,000 on PyPI
linear-tsvParses and writes tabular data in Linear TSV…
permissive · top 15,000 on PyPI
aiocsvProvides async-compatible CSV reading and…
permissive · top 5,000 on PyPI
csvwReads, writes, and validates tabular data…
permissive · top 5,000 on PyPI
latexcodecProvides a Python codec to convert between…
permissive · top 5,000 on PyPI
win_unicode_consoleFixes Unicode input and display in Python when…
permissive · top 15,000 on PyPI