Skip to main content

High-performance CSV parser with SIMD optimizations

Project description

CISV Python Bindings (nanobind)

High-performance Python bindings for the CISV CSV parser using nanobind.

Performance

These bindings are 10-100x faster than the ctypes-based bindings because they:

  1. Use the batch API: All data is parsed in C and returned at once, eliminating millions of per-field callbacks
  2. Use nanobind: Much lower overhead than ctypes or pybind11
  3. Release the GIL: Parallel parsing runs without holding the Python GIL
File Size ctypes nanobind Speedup
142MB (1M rows × 10 cols) ~20s <0.8s 25x+

Installation

From PyPI (recommended)

pip install cisv

From source

cd bindings/python-nanobind
pip install .

Development install

cd bindings/python-nanobind
pip install -e .

Usage

import cisv

# Parse a file
rows = cisv.parse_file('data.csv')

# Parse with options
rows = cisv.parse_file(
    'data.csv',
    delimiter=';',
    quote="'",
    trim=True,
    skip_empty_lines=True
)

# Parse large files in parallel (faster on multi-core systems)
rows = cisv.parse_file('large.csv', parallel=True)

# Parse a string
rows = cisv.parse_string("a,b,c\n1,2,3")

# Count rows quickly (SIMD-accelerated)
count = cisv.count_rows('data.csv')

API Reference

parse_file(path, delimiter=',', quote='"', *, trim=False, skip_empty_lines=False, parallel=False, num_threads=0)

Parse a CSV file and return all rows.

Parameters:

  • path: Path to the CSV file
  • delimiter: Field delimiter character (default: ',')
  • quote: Quote character (default: '"')
  • trim: Whether to trim whitespace from fields
  • skip_empty_lines: Whether to skip empty lines
  • parallel: Use multi-threaded parsing (faster for large files)
  • num_threads: Number of threads for parallel parsing (0 = auto-detect)

Returns: List of rows, where each row is a list of field values.

parse_string(content, delimiter=',', quote='"', *, trim=False, skip_empty_lines=False)

Parse a CSV string and return all rows.

Parameters:

  • content: CSV content as a string
  • delimiter: Field delimiter character (default: ',')
  • quote: Quote character (default: '"')
  • trim: Whether to trim whitespace from fields
  • skip_empty_lines: Whether to skip empty lines

Returns: List of rows, where each row is a list of field values.

count_rows(path)

Count the number of rows in a CSV file without full parsing.

This is very fast as it only scans for newlines using SIMD instructions.

Parameters:

  • path: Path to the CSV file

Returns: Number of rows in the file.

Running Tests

cd bindings/python-nanobind
pip install -e ".[test]"
pytest

Benchmarking

pip install -e ".[benchmark]"
python -c "
import cisv
import time

# Create test file
with open('/tmp/test.csv', 'w') as f:
    f.write('col1,col2,col3\n')
    for i in range(100000):
        f.write(f'value{i}_1,value{i}_2,value{i}_3\n')

# Benchmark
start = time.time()
rows = cisv.parse_file('/tmp/test.csv')
print(f'Parsed {len(rows)} rows in {time.time()-start:.3f}s')
"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cisv-0.2.3.tar.gz (41.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cisv-0.2.3-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (77.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

cisv-0.2.3-cp313-cp313-macosx_11_0_arm64.whl (53.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cisv-0.2.3-cp313-cp313-macosx_10_14_x86_64.whl (57.6 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

cisv-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (77.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

cisv-0.2.3-cp312-cp312-macosx_11_0_arm64.whl (54.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cisv-0.2.3-cp312-cp312-macosx_10_14_x86_64.whl (57.6 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

cisv-0.2.3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (77.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

cisv-0.2.3-cp311-cp311-macosx_11_0_arm64.whl (54.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cisv-0.2.3-cp311-cp311-macosx_10_14_x86_64.whl (57.7 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

cisv-0.2.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (77.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

cisv-0.2.3-cp310-cp310-macosx_11_0_arm64.whl (54.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

cisv-0.2.3-cp310-cp310-macosx_10_14_x86_64.whl (57.8 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

cisv-0.2.3-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (77.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

cisv-0.2.3-cp39-cp39-macosx_11_0_arm64.whl (54.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

cisv-0.2.3-cp39-cp39-macosx_10_14_x86_64.whl (57.9 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

File details

Details for the file cisv-0.2.3.tar.gz.

File metadata

  • Download URL: cisv-0.2.3.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cisv-0.2.3.tar.gz
Algorithm Hash digest
SHA256 a652a9b32f9743fd33fc77b1bed4f9276c5d9fb1c67d3aa096e318f8d5bb63e0
MD5 ef06fe731f7eccbda5b137aa063698bf
BLAKE2b-256 36a3b50e8cc6a8aa5f1c4703d09bf80df3f2c47758bce40de8576ce750822e04

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34b4b898ec472c452daf53b9170ec9ac0e73fd6aa75e02dfdd18fe727002934d
MD5 2aea57305ae440caa79ae4ed4990be29
BLAKE2b-256 e4bb4502ae016a01b7fac3fe5b7c85c978b0dc9691bf1aa85728cd07a0586386

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1192d0f0e156593028fc17fff0c7a9da61e17168510bc79c34c00fa76319141e
MD5 ff8f99a5939603427dc67b732ebcf4ac
BLAKE2b-256 5cdec4aaabd85d0b77763edbc78d1fc29cc474a6cf691c06f4b5bd2c5ca12d68

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp313-cp313-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 90778d897817ecbf9d644d57593edb75c27ad9072048d9bc8f564a249a71bcb3
MD5 1effb2567bd1ac343e7a6d71485a632e
BLAKE2b-256 d0cdfd08943252644da3a372dd22f31a899ab8348cb516c02d94c4092a53e88d

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 147ebdd5e7dd896b70ad3a70467321549eeadadc6935243027baeebd59fedead
MD5 2c2806b207470f3974d5ac6a82ba4035
BLAKE2b-256 bbd8ec9f2445d960e938e165d64655d94c05ada0ee6f7243baec6ba0b5f0b16a

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ecf4fe65386b9cca3ee928239fee06011760534bbf4250578dc00675fd4b593
MD5 089f8ef62448c215cb8ece7f4cdd4a7a
BLAKE2b-256 44bbfe73cb3936bb52287f5f5aa651e9c8a44bc000a5e586d7bb2cb0b65ca17e

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9dd1266d5421fcc15be9c1054a6f8ed01e490a3e8dfc05f161e898cf3480a56b
MD5 a0aacc8ed8276778e4f2aa564cc7b0ac
BLAKE2b-256 525b4c9866e4cda1f34ddb18d9b11747ed79714bd8e8b73bec803aa55d386536

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 524b7cfefec354c9ecb10bf80473ddb511aa1e544b37f21903a9b0639132eafe
MD5 496ebfd1748b018902cef5419ea2517c
BLAKE2b-256 48fd00e95e0097f1b9f0f927e9231f29a699841c28c6dbe9ab10d06f91e2df32

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b931ac1e73ab52a5e7883653ed930bacc138db6a91b709ff480c4c70297d5a6
MD5 2de44f8a735bae29cca79c2b7ca2ad42
BLAKE2b-256 e1bad84f3025ef038866ae3314c6fea7693d435a8f1135324cdc060f4be73213

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a3cfb2cac7487e2e9615c1e49f20acd1ce3a720a1ed3ddb5ed2448a574c6a018
MD5 f07d4b5148db2bf4b452527108fc46fd
BLAKE2b-256 f7895c63cd329d5920a449ff3cb9668a1095745bdc5ae62c6b5c85083c091ace

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6a390ef2288ef0251b7daace69e9bc5cdeb2918d5c4af2b257d096d15ce58b9e
MD5 0242d3c7cc2982f8a68755dee3286bd2
BLAKE2b-256 4167fea8ad809ecad1f09bd8472ef268aa7cfbae3d1ffe7de9f159f5bef12df0

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e862a151bf8b53ea6a9c22204eaa2c2150975442899b0477d1fe5c7a8c87a95
MD5 d9ceeef769546fc75d53c8b09742d72a
BLAKE2b-256 6be7e3a16a054afa2ed449863d925f467d5cdfda92044e2b38cccfefb6e7698b

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 e5e1f2ba95b0114c79f6562cd0d63141cba4dce096434beae3fc8a9e5f9b1a65
MD5 700edf2298e48046fc3266160161579f
BLAKE2b-256 9c9c08b02bc8c00cc32869b3557834ca2dbb303816d6f80e11b8fce42c3ec6d3

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9d7d8ecceafd6777820becb7e59ca842b39e6087abcc35103b9f6638f2ce43b6
MD5 68cd39efb6d47124f95fd49f6080e255
BLAKE2b-256 6c3484bbd48501222801df8a7fdb560bcacb6c3bd7e1b376ea2319f46e9cd553

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: cisv-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 54.5 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cisv-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b96ef00145a8e8e6ae3511c4ec71658cf1bed2c199c890b5669871a5c9c14ad
MD5 99626ebf6a47a43d59afcc6c55534cfb
BLAKE2b-256 d31528dbc413323098b894ea5bdc3813ff921359bbde7d2002e943ce9ecca961

See more details on using hashes here.

File details

Details for the file cisv-0.2.3-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.2.3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b48cca295d7a4e926c61ce977714866ae317ff23c47e3b0c731d7d441ce97508
MD5 a94992273c49088c35829a0a5bfa3e2e
BLAKE2b-256 41db4e0c75b765d0601b4c7c59d9e403f69978c146ad0b9424931be06be545de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page