Skip to main content

Fast CSV querying from Python — powered by a Zig/SIMD engine

Project description

csvql-query

CI License: MIT PyPI

Query CSV files with SQL from Python — powered by a Zig/SIMD engine.

Zero-copy mmap reads + SIMD parsing happen before Python ever sees the data. Faster than DuckDB on typical workloads, no dependencies required.

Installation

pip install csvql-query

Quick Start

import csvql

# Returns a list of dicts (like csv.DictReader, but with SQL)
rows = csvql.query("SELECT name, salary FROM 'employees.csv' WHERE salary > 100000 ORDER BY salary DESC")
# [{'name': 'Alice', 'salary': '185000'}, ...]

# Raw CSV string
csv_str = csvql.query_csv("SELECT * FROM 'data.csv' LIMIT 10")

# pandas DataFrame (pandas must be installed)
df = csvql.query_df("SELECT category, COUNT(*) as n FROM 'sales.csv' GROUP BY category")

# (headers, rows) tuples — no dependencies
headers, rows = csvql.query_tuples("SELECT name, age FROM 'users.csv' WHERE age > 25")

API

Function Returns Description
query(sql) list[dict] Execute SQL, get list of dicts
query_csv(sql) str Execute SQL, get raw CSV string
query_df(sql) DataFrame Execute SQL, get pandas DataFrame
query_tuples(sql) (list[str], list[tuple]) Execute SQL, get (headers, rows)

SQL Support

The SQL path is embedded in the query string (same as the CLI):

# Filtering, ordering, limiting
csvql.query("SELECT name, city FROM 'data.csv' WHERE age > 30 ORDER BY name LIMIT 5")

# Aggregation
csvql.query("SELECT department, AVG(salary) FROM 'emp.csv' GROUP BY department")

# Unix pipes — use '-' as the filename
import subprocess, sys
# or just pass stdin data via the engine directly

Full SQL reference: SIMPLE_QUERY_LANGUAGE.md

Performance

  • mmap + SIMD parsing — data is never copied into Python memory
  • Parallel chunk processing on multi-core machines
  • Typically 5–9x faster than DuckDB on 1M-row CSVs

Requirements

  • Python ≥ 3.10
  • macOS (x86_64 / arm64) or Linux (x86_64)
  • pandas optional — only needed for query_df()

Links

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

csvql_query-1.5.12-py3-none-manylinux_2_17_x86_64.whl (1.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

csvql_query-1.5.12-py3-none-macosx_12_0_x86_64.whl (353.0 kB view details)

Uploaded Python 3macOS 12.0+ x86-64

csvql_query-1.5.12-py3-none-macosx_12_0_arm64.whl (353.0 kB view details)

Uploaded Python 3macOS 12.0+ ARM64

File details

Details for the file csvql_query-1.5.12-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for csvql_query-1.5.12-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 e312e6c0e5e52867a3e4dbeb02ed56639e98664a1e591ee9bef9469ab8b2f0f2
MD5 33ac0a0a0fe9f6df439f9b5b6554c978
BLAKE2b-256 dbf1ae7a7dc00e7e360100835c8f5c33224e56ecbf0713baa423a720aa823b2d

See more details on using hashes here.

File details

Details for the file csvql_query-1.5.12-py3-none-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for csvql_query-1.5.12-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 e39f0ddd9ebb5fbfaf095f3c615027930fe232b605da6060820dbc688c736322
MD5 6d48a99a4b8951d3e6509a5ace3b5860
BLAKE2b-256 60c738a0940d1cf84ef46d1aa0f024273a9192dfb4b1f059693f51508479110f

See more details on using hashes here.

File details

Details for the file csvql_query-1.5.12-py3-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for csvql_query-1.5.12-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 16c3f79262f0aedcad13651c8ea9e8106ba004bd994413aa58c8596509d834cc
MD5 e91df06618a406bbc0ec32cf4d96abe3
BLAKE2b-256 077b47217e0c70e1b869c9263c95b96022096aa486a3f10eb79f297b87a2d996

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