Skip to content

CLI Reference

VisiGrid provides visigrid-cli for headless spreadsheet operations. Same engine as the desktop app, no GUI dependency. See Install to get set up.

Terminal window
# Sum a column from CSV
cat sales.csv | visigrid-cli calc "=SUM(A:A)" --from csv
# Diff two datasets by key
visigrid-cli diff before.csv after.csv --key name
# Replay a provenance script and verify fingerprint
visigrid-cli replay audit-trail.lua --verify
# Convert XLSX to JSON
visigrid-cli convert data.xlsx -t json --headers
# List all 96+ supported functions
visigrid-cli list-functions

Evaluate a spreadsheet formula against data from stdin or a file.

Terminal window
visigrid-cli 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 | visigrid-cli calc "=SUM(A:A)" --from csv
# Average with headers
echo -e "amount\n10\n20\n30" | visigrid-cli calc "=AVERAGE(A:A)" --from csv --headers
# Count lines in a file
cat file.txt | visigrid-cli calc "=COUNTA(A:A)" --from lines
# Conditional sum
cat sales.csv | visigrid-cli calc "=SUMIF(B:B, \">1000\", C:C)" --from csv
# Array formula with spill output
cat data.csv | visigrid-cli 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.


Reconcile two datasets by key column. Reports matched rows, rows only in left/right, and value differences with optional numeric tolerance.

Terminal window
visigrid-cli diff <left> <right> --key <column> [options]
OptionDescription
--keyKey column — name, letter (A), or 1-indexed number (required)
--matchMatching mode: exact (default) or contains (substring)
--key_transformTransform keys before matching: none, trim (default), digits
--compareColumns to compare (comma-separated; omit for all non-key)
--toleranceNumeric tolerance, absolute (default: 0)
--on_duplicatePolicy for duplicate keys: error (default)
--on_ambiguousPolicy for ambiguous matches (contains mode): error (default), report
--outOutput format: json (default) or csv
--outputOutput file (default: stdout)
--summarySummary destination: stderr (default), json, none
--no_headersTreat first row as data (generate A, B, C headers)
--header_rowHeader row number, 1-indexed
--delimiterCSV delimiter (default: ,)
Terminal window
# Basic diff by name column
visigrid-cli diff q3.csv q4.csv --key name
# With numeric tolerance (e.g., rounding differences)
visigrid-cli diff expected.csv actual.csv --key sku --tolerance 0.01
# Substring matching (left key contained in right key)
visigrid-cli diff short_codes.csv full_names.csv --key id --match contains --on_ambiguous report
# Compare specific columns only
visigrid-cli diff before.csv after.csv --key id --compare "price,quantity"
# CSV output to file
visigrid-cli diff left.csv right.csv --key name --out csv --output result.csv
{
"summary": {
"left_rows": 50,
"right_rows": 48,
"matched": 45,
"only_left": 5,
"only_right": 3,
"diff": 12,
"tolerance": 0.01,
"key": "name",
"match": "exact",
"key_transform": "trim"
},
"results": [
{
"status": "matched",
"key": "Alice",
"diffs": null
},
{
"status": "diff",
"key": "Bob",
"diffs": [
{ "column": "amount", "left": "1200", "right": "1350", "delta": 150.0, "within_tolerance": false }
]
},
{
"status": "only_left",
"key": "Carol"
}
]
}
TransformBehavior
noneCompare keys as-is
trimStrip leading/trailing whitespace (default)
digitsExtract only digits from keys

When --tolerance is set, numeric values are compared with absolute tolerance. Financial formats are parsed automatically ($1,234.56, parenthesized negatives like (500)). The within_tolerance field in output indicates whether a delta falls within the threshold.


Execute a Lua provenance script and optionally verify the output fingerprint.

Terminal window
visigrid-cli replay <script> [options]
OptionDescription
--verifyVerify fingerprint against script header (fail if mismatch)
--output, -oOutput file for resulting spreadsheet
--format, -fOutput format (inferred from extension if omitted)
--fingerprintPrint fingerprint and exit
--quiet, -qOnly print errors
Terminal window
# Replay and verify fingerprint matches
visigrid-cli replay audit-trail.lua --verify
# Replay and export result as CSV
visigrid-cli replay changes.lua --output snapshot.csv
# Just compute the fingerprint
visigrid-cli replay changes.lua --fingerprint
# Quiet mode for CI
visigrid-cli replay changes.lua --verify --quiet

Every edit in VisiGrid can generate a Lua provenance script — a complete, ordered record of what changed. These scripts are plain text and version-control friendly.

-- VisiGrid provenance script
-- Generated: 2025-01-15T09:42:00Z
-- Fingerprint: v1:6:a3f8c2d1
sheet:set("A1", "Revenue")
sheet:set("A2", 42850)
sheet:set("A3", 38100)
sheet:set("B1", "Total")
sheet:set("B2", "=SUM(A2:A3)")

Fingerprints use the format v1:<length>:<hash>. The hash is computed from the final spreadsheet state. Scripts containing nondeterministic functions (NOW, TODAY, RAND, RANDBETWEEN) cannot be verified — --verify will fail with an error.

$ visigrid-cli replay audit-trail.lua --verify
Replayed 12 operations
Fingerprint: v1:6:a3f8c2d1
Verification: PASS (matches expected)

If the source data or the script has been modified, verification fails with a non-zero exit code.


Convert between file formats.

Terminal window
visigrid-cli convert [input] -t <format> [options]
OptionDescription
--from, -fInput format (required when reading from stdin)
--to, -tOutput format: csv, tsv, json, lines (required)
--output, -oOutput file (default: stdout)
--sheetSheet name for multi-sheet files (default: first)
--delimiterCSV/TSV delimiter (default: , for csv, \t for tsv)
--headersFirst row is headers (affects JSON object keys)
Terminal window
# XLSX to JSON with headers as keys
visigrid-cli convert data.xlsx -t json --headers
# CSV to JSON via stdin
cat data.csv | visigrid-cli convert -f csv -t json
# JSON to CSV
curl -s api.example.com/data | visigrid-cli convert -f json -t csv
# Select a specific sheet from XLSX
visigrid-cli convert report.xlsx -t csv --sheet "Q4 Data"
# File to file
visigrid-cli convert data.xlsx -t csv -o data.csv
FormatExtensionsReadWrite
csv.csvyesyes
tsv.tsvyesyes
json.jsonyesyes
linesyesyes
xlsx.xlsx, .xlsyes
sheet.sheetyesyes

When reading from a file, the format is inferred from the extension. Use --from to override or when reading from stdin.


Print all supported spreadsheet functions.

Terminal window
visigrid-cli list-functions

Outputs one function name per line, sorted alphabetically. Suitable for grep and wc -l.

$ visigrid-cli list-functions | head -5
ABS
ACOS
AND
AVERAGE
AVERAGEIF

96+ functions are supported — the same engine that powers the desktop app.


Launch the desktop GUI, optionally opening a file.

Terminal window
visigrid-cli open [file]

Looks for VisiGrid.app on macOS or visigrid-gui in PATH on Linux/Windows.


CodeMeaning
0Success
1Evaluation error (formula error, spill without --spill)
2Invalid arguments
3I/O error (also: duplicate keys in diff)
4Parse error (malformed input; also: ambiguous matches in diff)
5Format error (unsupported format; also: diff parse error)
  • stdout is the data stream. Pipe it, redirect it, parse it.
  • stderr is diagnostics. Error messages, warnings, summaries.
  • Exit code is truth for pipelines. Non-zero on any error.