← All one-liners·#010·analysis·self contained·power

CSV → instant stats with Miller

Miller (`mlr`) does what jq can't: real aggregation. Drop a CSV in, get group-by stats out. Lighter than DuckDB when you just want quick verbs.

Setup
  • → brew install miller
Cost per run
free
The one-liner
$ mlr --csv stats1 -a mean,p90,max -f price -g category sales.csv | column -t
What each stage does
  1. [01] mlrmlr --csv stats1 -a mean,p90,max -f price -g category sales.csv
    Read sales.csv as CSV (--csv). Run the stats1 verb: compute mean/p90/max (-a) over the 'price' column (-f), grouped by 'category' (-g). Output is still CSV.
  2. [02] columncolumn -t
    Align CSV-as-table for human reading. Pure presentation.
Expected output (sample)
category    price_mean  price_p90  price_max
electronics  142.40      280.00     899.00
books        18.20       29.95      85.00
apparel      52.10       110.00     245.00
Caveats & tips
  • mlr can also do `--ij2t` (JSON → TSV), `stats2` for correlations, `having-fields`, `tac` (reverse), `decimate`, and 50 more verbs.
  • For JSON in / TSV out with the same verbs: `mlr --j2t stats1 -a mean -f score data.json`