csv_diff
Compare two CSV or TSV files to report added, removed, and changed rows, per-cell differences, and column changes, with optional key columns for row matching.
Instructions
Row-level diff of two CSV/TSV files: added, removed and changed rows, per-cell changes, columns.
Rows are paired by key_columns (e.g. ["id"] or ["country", "year"]); without key_columns whole rows are compared as an unordered set, so an edited row appears as one removed plus one added row. Reports added/removed columns separately (cells of those columns are not compared) and whether the common columns were reordered. Duplicate keys are paired in file order and reported as a warning. The delimiter (, ; tab |) and BOM/UTF-16 encodings are detected automatically. File a is indexed in memory (limit 2 million rows); file b is streamed.
Args: a, b: file paths. key_columns: column names identifying a row; they must exist in both files. ignore_columns: column names or globs (e.g. "updated_*") whose cells are not compared. delimiter: a single character; auto-detected when omitted. abs_tol, rel_tol: numeric cells (both sides parse as numbers) within tolerance are equal; requires key_columns. max_changes: cap on entries in each of added_rows, removed_rows and changed_rows; summary counts are always complete.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes | ||
| abs_tol | No | ||
| rel_tol | No | ||
| encoding | No | auto | |
| delimiter | No | ||
| key_columns | No | ||
| max_changes | No | ||
| ignore_columns | No | ||
| max_value_chars | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||