KilnVM Live Labs /lab/miller-csv-json-wrangling-lab
Step 1 of 3 Docs Build Your Own

Fast CSV Transforms, Aggregations and JSON Export with Miller

Compute derived columns on CSV data with mlr put, aggregate regional metrics with stats1, and convert tabular summaries into JSON offline.

Step 1 of 3

Add calculated profit and margin fields with mlr put

/workspace/orders.csv tracks order revenue and cost. Use mlr --csv put to add profit and margin_pct, saving output to enriched.csv:

bash
mlr --csv put '$profit = $rev - $cost; $margin_pct = round(100 * $profit / $rev)' orders.csv > enriched.csv && cat enriched.csv

Click Check Step to continue.