csvpeek
A fast, zero-dependency CSV profiler for the terminal. Point it at a file and get column types, null counts, numeric statistics, and top values, in one glance.
Pure Python standard library. Deterministic: the same file always produces the same profile. No pandas, no install-time downloads, nothing leaves your machine.
$ csvpeek examples/people.csv
6 rows × 5 columns
column type nulls unique summary
────────────────────────────────────────
name string 0 6 Ann (1), Bob (1), Cara (1), Dan (1), Eve (1)
age int 1 (16.7%) 4 min 22 · p25 25.5 · median 29 · p75 37.5 · max 41 · mean 31 · sd 6.2929 · hist ▅▁▁█▁▁▅▁▁▅
city string 0 3 Santa Cruz (3), Brentwood (2), Oakland (1)
active bool 0 2 true (4), false (2)
score float 1 (16.7%) 5 min 6.5 · p25 6.8 · median 8.8 · p75 9.2 · max 9.4 · mean 8.16 · sd 1.143 · hist █▁█▁▁▁▁███
Install
Requires Python 3.9+.
pip install csvpeek-cli
The distribution is csvpeek-cli because csvpeek on PyPI belongs to an
unrelated project. The command, the import and this repository are all still
csvpeek; only the string after pip install differs.
Or run it straight from a clone, no install needed:
python -m csvpeek data.csv
Usage
csvpeek data.csv # profile a CSV
cat data.csv | csvpeek - # read from standard input
csvpeek data.tsv -d $'\t' # tab-separated
csvpeek data.csv --top 10 # more top values for text columns
csvpeek big.csv -n 10000 # sample the first 10k rows of a large file
csvpeek data.csv -c age,city # profile only these columns, in this order
csvpeek data.csv --format md # a Markdown table to paste into a PR
csvpeek data.csv --json # machine-readable output
csvpeek data.csv --no-color # plain text
| Flag | Description |
|---|---|
-d, --delimiter |
Field delimiter (default: auto-detect , ; tab |) |
-t, --top N |
Show top N values for text columns (default 5) |
-n, --limit ROWS |
Only read the first ROWS data rows (sample large files) |
-c, --columns A,B,C |
Profile only these columns, comma-separated, in the order given |
--format {table,md,json} |
Output format: table (default), md (Markdown), or json |
--json |
Shortcut for --format json |
--encoding ENC |
Input text encoding (default utf-8-sig); try cp1252 or latin-1 |
--no-color |
Disable colored output |
-V, --version |
Print version |
What it computes
- Type inference per column:
int,float,bool,date,string, orempty. A column takes a type only if every non-null value fits; one stray label keeps it a string (no silent coercion). Dates require a separator (2024-01-01,01/02/2024), so bare years and ids stay numeric. - Nulls: empty,
NA,N/A,null,none,nan,nil(case-insensitive), with a percentage. - Numeric columns: min, 25th/50th/75th percentiles, max, mean, and population
standard deviation, plus a small histogram of the values bucketed into ten
bins, shown as a sparkline in the table and as
edges/countsin the JSON. - Text/bool columns: unique count and the most common values (ties broken alphabetically, so runs are reproducible).
- Near misses: a
stringcolumn that is mostly one type says so, and names the values stopping it,mostly int, 2 not: "twelve", "x". This is the question a profile usually raises and rarely answers: the column was supposed to be a number, and finding the two rows that ruined it otherwise means grepping.
Library
Everything the CLI does is available as a small API:
from csvpeek import profile_file
profile = profile_file("data.csv")
print(profile.rows)
for col in profile.columns:
print(col.name, col.dtype, col.nulls, col.mean)
profile.to_dict() # JSON-ready
Documentation
| Document | What it covers |
|---|---|
| docs/cli.md | Every flag, output format, and exit code |
| docs/profiling.md | The exact rules behind every number csvpeek prints |
| docs/api.md | Using csvpeek as a library |
Development
pip install pytest .
pytest -q
Related
Four small tools that each do one thing to a table of data:
- csvpeek profiles a file: column types, null counts, distributions.
- sift queries one: filter, sort, aggregate, streaming.
- drift diffs two of them, in Rust.
- quarry is the long way round, a hand-written SQL parser and executor meant to be read.
License
MIT © Martin Muskov
Metadata
Release files for csvpeek-cli 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| csvpeek_cli-1.2.0.tar.gz | 41.8 kB | Without provenance | Details for csvpeek_cli-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| csvpeek_cli-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for csvpeek_cli-1.2.0-py3-none-any.whl |
Total release size: 60.1 kB
Release files / csvpeek_cli-1.2.0.tar.gz
| Download URL | csvpeek_cli-1.2.0.tar.gz |
|---|---|
| Size | 41.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c88f83369be95700d28e4db2b0063587233116bfaa21ef24af707074e8e64c62
|
|
BLAKE2b-256 checksum How to use checksums |
00b026488459d86fd566e153377db648f7c4e3eb405590d6505a7271b5e993bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / csvpeek_cli-1.2.0-py3-none-any.whl
| Download URL | csvpeek_cli-1.2.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39a669f52c5409e864e06c3047aa0e59c351027334bbd7ff897e0e181146b7a9
|
|
BLAKE2b-256 checksum How to use checksums |
a3a0f1789e86f43c2ee51b2270859f35a5b5df4d00169e6f1f3abf1ec236ccc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for csvpeek-cli 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.