tsv2py
High-performance parser and generator for PostgreSQL-compatible tab-separated values (TSV)
What it is and what it does
tsv2py is a native-code parser and generator for tab-separated values (TSV) data, optimized for bulk data transfer between Python and databases like PostgreSQL. It converts TSV records into Python tuples of typed objects—supporting bytes, strings, integers, floats, booleans, dates, datetimes, UUIDs, decimals, IP addresses, and JSON structures—and can generate TSV output from tuples. The implementation uses AVX2 SIMD instructions for date-time parsing, UUID parsing, and field delimiter detection, and calls C standard library functions for integer parsing and IP address validation.
The package is designed as a high-performance alternative to Python standard-library approaches for TSV handling, particularly for scenarios involving PostgreSQL COPY operations or bulk data import/export. It supports the PostgreSQL text format (a TSV variant with backslash-escaped special characters) and handles the full escape sequence set including NULL values, control characters, and backslashes. Prebuilt wheels are available for modern Python versions on macOS, Linux, Windows, and PyPy, reducing installation friction on common platforms.
Use it for:
- Bulk import or export of data from PostgreSQL using the COPY command with text format.
- High-speed parsing of large TSV files with mixed data types into Python objects.
- Converting database query results into TSV for transfer to another system or database.
- Generating TSV output from Python data structures for database ingestion.
- Processing RFC 3339 timestamps and RFC 4122 UUIDs embedded in TSV records.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and generates tab-separated values (TSV) data with high performance, converting between TSV text files and Python objects with support for multiple data types including dates, UUIDs, decimals, and IP addresses.
Yes, if you work with TSV data or PostgreSQL bulk operations and need performance beyond the standard library. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and offers prebuilt wheels for most platforms. Install friction is moderate but manageable; only consider it a blocker if you cannot install a C compiler on your target system.
Install
tsv2py on PyPI
pip
pip install tsv2pyuv
uv add tsv2pypoetry
poetry add tsv2pyInstalling tsv2py
Before you install
Medium install friction due to native C code, but prebuilt wheels cover major platforms (macOS arm64, Linux x86_64/i686, Windows, and PyPy variants). Requires a C compiler and Python development headers only if no wheel matches your platform.
License in practice
MIT license is permissive; you can use, modify, and distribute tsv2py freely in commercial and private projects with minimal restrictions.
Quickstart
from tsv2py.helper import Parser
from uuid import UUID
from datetime import date, datetime
parser = Parser(fields=(str, int, date, datetime, UUID, bool))
with open('data.tsv', 'rb') as f:
records = parser.parse_file(f)
Requires Python 3.10 or later; if no prebuilt wheel is available for your platform, a C compiler and Python development headers are needed to build from source.
Verify before relying
- Whether orjson is an optional dependency that improves JSON parsing performance, or if the fallback to built-in json is automatic.
- Whether the package handles streaming large TSV files efficiently or if parse_file loads the entire file into memory.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 49 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 94,918/month — #13,298 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tsv2py-0.8.0-cp310-abi3-macosx_11_0_arm64.whl; tsv2py-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tsv2py-0.8.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; tsv2py-0.8.0-cp310-abi3-musllinux_1_2_i686.whl; tsv2py-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl; tsv2py-0.8.0-cp310-abi3-win32.whl; tsv2py-0.8.0-cp310-abi3-win_amd64.whl; tsv2py-0.8.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl; tsv2py-0.8.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tsv2py-0.8.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; tsv2py-0.8.0-pp310-pypy310_pp73-win_amd64.whl; tsv2py-0.8.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl; tsv2py-0.8.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tsv2py-0.8.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; tsv2py-0.8.0-pp311-pypy311_pp73-win_amd64.whl
Tags
More File Formats packages
msgpack serializes and deserializes Python…
permissive · top 1,000 on PyPI
pyelftoolspyelftools parses and analyzes ELF binary files…
permissive · top 5,000 on PyPI
python-oxmsgParses Outlook MSG files to extract email…
permissive · top 5,000 on PyPI
stringzillaStringZilla provides SIMD and SWAR-accelerated…
permissive · top 5,000 on PyPI
borbborb reads, writes, and manipulates PDF files…
agpl · top 15,000 on PyPI
protobuf-pyGenerates well-typed, readable Python code from…
permissive · top 15,000 on PyPI
linear-tsvParses and writes tabular data in Linear TSV…
permissive · top 15,000 on PyPI
pgcopypgcopy wraps PostgreSQL's binary COPY protocol…
permissive · top 15,000 on PyPI
pytablewriterConverts tabular data into formatted tables for…
permissive · top 5,000 on PyPI
detect-delimiterDetects the delimiter character used in CSV,…
permissive · top 15,000 on PyPI
parquetReads Apache Parquet files in pure Python and…
permissive · top 15,000 on PyPI
tablibTablib converts tabular data between multiple…
permissive · top 5,000 on PyPI
csv-diffCompares two CSV, TSV, or JSON files and…
permissive · top 15,000 on PyPI
isodateParses and formats ISO 8601 date, time,…
permissive · top 1,000 on PyPI
tabulatorReads and writes tabular data in multiple…
permissive · top 15,000 on PyPI
sttableParses string-formatted tables (with…
permissive · top 15,000 on PyPI