Skip to content

vgrid calc

Evaluate a spreadsheet formula against data piped from stdin.

Terminal window
vgrid calc <formula> --from <format> [options]
OptionDescription
--from, -fInput format: csv, tsv, json, lines, xlsx (required)
--headersFirst row is headers (excluded from formulas)
--intoLoad data starting at cell (default: A1)
--delimiterCSV delimiter (default: ,)
--spillOutput format for array results: csv or json
Terminal window
# Sum a column
cat data.csv | vgrid calc "=SUM(A:A)" --from csv
# Average with headers
echo -e "amount\n10\n20\n30" | vgrid calc "=AVERAGE(A:A)" --from csv --headers
# Count lines in a file
cat file.txt | vgrid calc "=COUNTA(A:A)" --from lines
# Conditional sum
cat sales.csv | vgrid calc "=SUMIF(B:B, \">1000\", C:C)" --from csv
# Array formula with spill output
cat data.csv | vgrid calc "=FILTER(A:A, B:B>10)" --from csv --spill json
ResultBehavior
ScalarPrint raw value to stdout, exit 0
Error tokenPrint token (e.g., #DIV/0!) to stdout, diagnostic to stderr, exit 1
ArrayRequires --spill. Without it, exit 1 with size hint.

Numbers print as raw values without locale formatting: 1234.5678 not $1,234.57.