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, column2WHERE 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
- Name: Jahfar Muhammed
- GitHub: jah-117
- Email: jahfarbinmuhammed117@gmail.com
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61f392d2d639d672ecb9afc2f2836313e1bbd12f664445a9648ca9559e24c32b
|
|
| MD5 |
30a0b0be531df0b48f7415485b64926d
|
|
| BLAKE2b-256 |
6dd32514b8de100555cbe845f93d000a3cc71ad54277201addd3df512f7c9ea9
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8799eb236ccce41dd59484a8a28782d791b8fe7ac03a5b3dce01db65f29d08e1
|
|
| MD5 |
1b58f96bfbf3c73272c07f7bb6f54ad0
|
|
| BLAKE2b-256 |
2a2714f2e148943cee47e0e9ebf45ff7b1497cc73c1b8bf98ae83d2544729cdd
|