Skip to main content

Run SQL-like queries on CSV files using a simple Python library or CLI.

Project description

csvquerylite

csvquerylite is a lightweight Python library and command-line tool that allows you to run SQL-like queries on CSV files easily. It’s designed for developers, analysts, and anyone who wants the power of SQL for CSV data without setting up a database.


Features

  • Simple SQL-like syntax: SELECT, WHERE, ORDER BY, LIMIT
  • Command-line interface (CLI) support
  • Save output as CSV or JSON
  • Pure Python + Pandas implementation
  • Works on any CSV file

Sample Usage (Python API)

from csv_query.core import query_csv

df = query_csv("employees.csv", "SELECT name, age WHERE department == 'HR' ORDER BY age DESC LIMIT 2")
print(df)

Sample Usage (CLI)

csv-query employees.csv "SELECT name, age WHERE age > 30 ORDER BY age DESC LIMIT 5"

To save output:

csv-query employees.csv "SELECT name, salary WHERE department == 'Engineering'" --output eng.csv
csv-query employees.csv "SELECT * ORDER BY age DESC LIMIT 3" --json top3.json

Installation

Install dependencies and install locally:

git clone https://github.com/your-username/csv-query.git
cd csv-query
pip install -e .

Command-Line Options

csv-query <file.csv> "<query>" [--output result.csv] [--json result.json]
Option Description
file.csv CSV file to query
"<query>" SQL-like query string
--output Save result as CSV
--json Save result as JSON

Supported Syntax

Basic SQL-like support:

  • SELECT column1, column2
  • WHERE condition (use pandas-style conditions)
  • ORDER BY column [ASC|DESC]
  • LIMIT N

Example: SELECT name, salary WHERE department == 'Finance' ORDER BY salary DESC LIMIT 3


Roadmap

  • SELECT, WHERE, ORDER BY, LIMIT
  • CLI with CSV/JSON export
  • Column aliasing (AS)
  • JOIN support
  • PyPI publishing
  • Unit testing with pytest

Author


License

This project is licensed under the MIT License - see the LICENSE file for details.

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

csvquerylite-0.1.5.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

csvquerylite-0.1.5-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file csvquerylite-0.1.5.tar.gz.

File metadata

  • Download URL: csvquerylite-0.1.5.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for csvquerylite-0.1.5.tar.gz
Algorithm Hash digest
SHA256 61f392d2d639d672ecb9afc2f2836313e1bbd12f664445a9648ca9559e24c32b
MD5 30a0b0be531df0b48f7415485b64926d
BLAKE2b-256 6dd32514b8de100555cbe845f93d000a3cc71ad54277201addd3df512f7c9ea9

See more details on using hashes here.

File details

Details for the file csvquerylite-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: csvquerylite-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for csvquerylite-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8799eb236ccce41dd59484a8a28782d791b8fe7ac03a5b3dce01db65f29d08e1
MD5 1b58f96bfbf3c73272c07f7bb6f54ad0
BLAKE2b-256 2a2714f2e148943cee47e0e9ebf45ff7b1497cc73c1b8bf98ae83d2544729cdd

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