csvkit csvstat: Summary Statistics for CSV
csvstat profiles a CSV, reporting each column's inferred type, null count, min/max, mean and most common values.
Before trusting a CSV in a pipeline, csvstat tells you what is actually in it: which columns are numeric, where the nulls are, and how many unique values exist.
What it does
csvstat reads a CSV and prints a profile per column: data type, count of nulls, unique values, min/max/mean/median for numbers, and the most frequent values. Single-stat flags like --nulls or --mean restrict it to one measure.
Common usage
# full profile of every column
csvstat data.csv
# just the null counts (good for a data-quality gate)
csvstat --nulls data.csv
# mean of a single column
csvstat -c amount --mean data.csvOptions
| Flag | What it does |
|---|---|
| -c, --columns <list> | Restrict to specific columns |
| --nulls | Print only the null counts |
| --unique | Print only the count of unique values |
| --mean / --median / --sum | Print only that statistic |
| --max / --min | Print only the max / min |
| --freq-count <n> | Number of frequent values to show |
In CI
Gate on data quality without writing parsing code: capture csvstat --nulls report.csv and fail if a required column has nulls, or assert csvstat -c id --unique equals the row count to catch duplicate IDs in an exported dataset.
Common errors in CI
csvstat reads the whole file into memory and is slow on large CSVs; for multi-GB inputs prefer xsv stats. UnicodeDecodeError again signals a non-UTF-8 encoding; pass -e latin-1. If a numeric column shows type Text, a stray non-numeric value (like N/A) defeated inference; csvstat's --mean then errors or reports nothing for that column.