@asdsadw12312dwd2112xz/csv-query-cli
v1.0.0
Published
Query CSV files with SQL-like syntax from the terminal
Readme
csv-query-cli
Query CSV files with SQL-like syntax right from your terminal.
Install
npm install -g csv-query-cli
# or run locally after build:
node dist/index.js <file> [options]Build
npm install
npm run buildUsage
csv-query-cli <file> [options]Options
| Flag | Description |
|------|-------------|
| -w, --where <expr> | Filter rows: col=value, col>10, col!=foo |
| -s, --select <cols> | Comma-separated columns to show |
| --sort <col> | Sort by column (prefix - for descending, e.g. -age) |
| -l, --limit <n> | Limit output to N rows |
| -c, --count | Print matching row count only |
| --stats | Show column statistics (min, max, avg, median, unique) |
| -d, --delimiter <char> | Field delimiter (default: ,) |
Operators for --where
= != > < >= <=
Numeric comparisons are used when both sides are valid numbers; otherwise falls back to string comparison.
Examples
# Show entire file as table
csv-query-cli data.csv
# Filter rows
csv-query-cli data.csv --where "age>25"
csv-query-cli data.csv --where "city=London"
# Select specific columns
csv-query-cli data.csv --select "name,age,city"
# Combine filter + select + sort + limit
csv-query-cli data.csv --where "age>=18" --select "name,age" --sort "-age" --limit 10
# Count matching rows
csv-query-cli data.csv --where "status=active" --count
# Column statistics
csv-query-cli data.csv --stats
csv-query-cli data.csv --select "salary,age" --stats
# Custom delimiter (TSV)
csv-query-cli data.tsv --delimiter $'\t'
# Semicolon-separated
csv-query-cli data.csv --delimiter ";"Sample CSV
name,age,city,salary
Alice,30,London,75000
Bob,24,Paris,55000
Carol,35,London,90000
Dave,28,Berlin,62000csv-query-cli sample.csv --where "city=London" --sort "-salary"
# ┌──────┬─────┬────────┬────────┐
# │ name │ age │ city │ salary │
# ├──────┼─────┼────────┼────────┤
# │ Carol│ 35 │ London │ 90000 │
# │ Alice│ 30 │ London │ 75000 │
# └──────┴─────┴────────┴────────┘
# 2 row(s)