Skip to main content

High-performance CSV parser with SIMD optimizations (AVX-512/AVX2)

Project description

CISV Python Binding

High-performance CSV parser with SIMD optimizations for Python.

Requirements

  • Python 3.7+
  • CISV core library (libcisv.so)

Installation

Build Core Library First

cd ../../core
make

Install Python Package

pip install -e .

Or using the Makefile:

make build

Quick Start

from cisv import CisvParser, parse_file, parse_string, count_rows

# Simple file parsing
rows = parse_file('data.csv')
for row in rows:
    print(row)

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

# Parse from string
csv_data = """name,age,email
John,30,john@example.com
Jane,25,jane@example.com"""

rows = parse_string(csv_data)

# Fast row counting (without full parsing)
total = count_rows('large.csv')
print(f"Total rows: {total}")

API Reference

CisvParser Class

class CisvParser:
    def __init__(
        self,
        delimiter: str = ',',
        quote: str = '"',
        escape: Optional[str] = None,
        comment: Optional[str] = None,
        trim: bool = False,
        skip_empty_lines: bool = False,
    ):
        """
        Create a new CSV parser.

        Args:
            delimiter: Field separator character (default: ',')
            quote: Quote character for fields (default: '"')
            escape: Escape character (default: None for RFC4180 "" style)
            comment: Comment line prefix (default: None)
            trim: Strip whitespace from fields (default: False)
            skip_empty_lines: Skip empty lines (default: False)
        """

    def parse_file(self, path: str) -> List[List[str]]:
        """Parse a CSV file and return all rows."""

    def parse_string(self, content: str) -> List[List[str]]:
        """Parse a CSV string and return all rows."""

Convenience Functions

def parse_file(
    path: str,
    delimiter: str = ',',
    quote: str = '"',
    **kwargs
) -> List[List[str]]:
    """Parse a CSV file with the given options."""

def parse_string(
    content: str,
    delimiter: str = ',',
    quote: str = '"',
    **kwargs
) -> List[List[str]]:
    """Parse a CSV string with the given options."""

def count_rows(path: str) -> int:
    """Count rows in a CSV file without full parsing."""

Configuration Options

Option Type Default Description
delimiter str ',' Field delimiter character
quote str '"' Quote character
escape str None Escape character
comment str None Comment line prefix
trim bool False Trim whitespace from fields
skip_empty_lines bool False Skip empty lines

Examples

TSV Parsing

from cisv import CisvParser

parser = CisvParser(delimiter='\t')
rows = parser.parse_file('data.tsv')

Skip Comments and Empty Lines

parser = CisvParser(
    comment='#',
    skip_empty_lines=True,
    trim=True
)
rows = parser.parse_file('config.csv')

Parse CSV String

from cisv import parse_string

data = """
id,name,value
1,foo,100
2,bar,200
"""

rows = parse_string(data, trim=True)
# [['id', 'name', 'value'], ['1', 'foo', '100'], ['2', 'bar', '200']]

Performance

CISV uses SIMD optimizations (AVX-512, AVX2, SSE2) for high-performance parsing. The Python binding uses ctypes to call directly into the native C library with minimal overhead.

Typical performance on modern hardware:

  • 500MB+ CSV files parsed in under 1 second
  • 10-50x faster than pure Python CSV parsers

License

MIT

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.0.75.tar.gz (63.8 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.0.75-py3-none-manylinux_2_35_x86_64.whl (34.8 kB view details)

Uploaded Python 3manylinux: glibc 2.35+ x86-64

cisv-0.0.75-py3-none-macosx_11_0_arm64.whl (21.0 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for cisv-0.0.75.tar.gz
Algorithm Hash digest
SHA256 06c2d8105c8c4192cd78b58261e2db7fdb11b99dcb2dd1b2fa1c2c41f58964bd
MD5 207e34110562603727be5996ff07dc1e
BLAKE2b-256 ef9b411916e174bdf77b8f68f3a5e5701a606d40d773ef4b6ea04a1fb04f12be

See more details on using hashes here.

File details

Details for the file cisv-0.0.75-py3-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for cisv-0.0.75-py3-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 f39a67a2779aa99da8b4db4e2c7931f759af4193e0fe646156040936d2d828d6
MD5 fb2ca156bed494359b2ce652d4449e58
BLAKE2b-256 6e1234ef3237635b95e87b02be9970df7913b2c1e151b41d893f6922a92fb75f

See more details on using hashes here.

File details

Details for the file cisv-0.0.75-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: cisv-0.0.75-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3, 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.0.75-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ddb783ce92f2f6029f5b0997153c0b8cacff98c602b74069d5b267f016557213
MD5 1484b12c24b7a658770762dd4366fb02
BLAKE2b-256 b6ecc72fca43f60304f627bd69b5579f15099b1eef544ee72f9523088722a339

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