vgrid calc
Evaluate a spreadsheet formula against data piped from stdin.
vgrid calc <formula> --from <format> [options]| Option | Description |
|---|---|
--from, -f | Input format: csv, tsv, json, lines, xlsx (required) |
--headers | First row is headers (excluded from formulas) |
--into | Load data starting at cell (default: A1) |
--delimiter | CSV delimiter (default: ,) |
--spill | Output format for array results: csv or json |
Examples
Section titled “Examples”# Sum a columncat data.csv | vgrid calc "=SUM(A:A)" --from csv
# Average with headersecho -e "amount\n10\n20\n30" | vgrid calc "=AVERAGE(A:A)" --from csv --headers
# Count lines in a filecat file.txt | vgrid calc "=COUNTA(A:A)" --from lines
# Conditional sumcat sales.csv | vgrid calc "=SUMIF(B:B, \">1000\", C:C)" --from csv
# Array formula with spill outputcat data.csv | vgrid calc "=FILTER(A:A, B:B>10)" --from csv --spill jsonOutput rules
Section titled “Output rules”| Result | Behavior |
|---|---|
| Scalar | Print raw value to stdout, exit 0 |
| Error token | Print token (e.g., #DIV/0!) to stdout, diagnostic to stderr, exit 1 |
| Array | Requires --spill. Without it, exit 1 with size hint. |
Numbers print as raw values without locale formatting: 1234.5678 not $1,234.57.