skillfed

tsv2py

High-performance parser and generator for PostgreSQL-compatible tab-separated values (TSV)

tsv2py v0.8.0 94.9K downloads/30d#13,298 on PyPI0
Permissive license MIT Active released

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 tsv2py

uv

uv add tsv2py

poetry

poetry add tsv2py

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: CProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: File FormatsTyping :: Typed

Tags

tsv parser pythontab-separated values parsingpostgresql copy formathigh-performance tsv readertsv to python objectsbulk data import exportdatabase data transfer
tsv-parsingpostgresqlbulk-data-transfer

More File Formats packages