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.10-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.10-py3-none-macosx_12_0_x86_64.whl (353.0 kB view details)

Uploaded Python 3macOS 12.0+ x86-64

csvql_query-1.5.10-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.10-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for csvql_query-1.5.10-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 beb50bdc007e4c35d083400bb0b5d9848d06031a181bc9bbb9e85a4cd278c476
MD5 99a372b620d8ac5bd69bb3891ec6ab54
BLAKE2b-256 59033fccc595a9920cb7f0db0eba546eb0bea2c819de5ec18715e393df2d8a47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for csvql_query-1.5.10-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 3b6a4521b9693857e5a0d48906f0564b54cfcf20ebf5c2703a03f6df896227c7
MD5 d873232c984bd7b27ce85864407d262d
BLAKE2b-256 8adc2171eb235bf9417ddcba109e7490b47cc9fad32beb88c02c2169905ca3e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for csvql_query-1.5.10-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 6389e278246a3d5b4f967ce51790625fbf54a47f1d388463a8dc9ff01a7d04ec
MD5 2159275ee0565d711133d02a3cb4bc44
BLAKE2b-256 52ce0929fc56d3c10e7c64310064e08880a312ee0660f5e955420819eaf54ec7

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