csv-diff

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

CSV Diff

CSV 差异对比

Compare two CSV files to identify changes, additions, or deletions between them and generate a unified diff output similar to
git diff
.
比较两个CSV文件,识别它们之间的修改、新增或删除内容,并生成类似
git diff
的统一diff输出。

When to use

适用场景

Use this when you need to:
  • Compare two CSV files and see what changed between them, especially for large datasets.
  • Generate a unified diff file for tracking changes in tabular data.
当你需要以下操作时使用:
  • 比较两个CSV文件并查看它们之间的变化,尤其是针对大型数据集。
  • 生成统一diff文件以跟踪表格数据的变化。

Quick start

快速开始

Compare two CSV files:
bash
csvdiff old.csv new.csv
This will generate a
result.diff
file showing the differences.
比较两个CSV文件:
bash
csvdiff old.csv new.csv
这将生成一个显示差异的
result.diff
文件。

Documentation

文档

  • Run
    csvdiff --help
    to see available options and usage.
  • Read the documentation for more details.
  • 运行
    csvdiff --help
    查看可用选项和使用方法。
  • 阅读文档了解更多详细信息。

Output

输出结果

The tool generates a unified diff output similar to the following:
diff
--- old.csv
+++ new.csv
@@ -2,3 +2,3 @@
 0,Alice,70000
-1,John,50000
+1,John,55000
 2,Jane,60000
The output shows:
  • Lines prefixed with
    -
    were removed or changed
  • Lines prefixed with
    +
    were added or changed
  • Context lines (no prefix) show unchanged data for reference
该工具生成如下所示的统一diff输出:
diff
--- old.csv
+++ new.csv
@@ -2,3 +2,3 @@
 0,Alice,70000
-1,John,50000
+1,John,55000
 2,Jane,60000
输出内容说明:
  • -
    开头的行表示被删除或修改的内容
  • +
    开头的行表示被新增或修改的内容
  • 无前缀的上下文行显示未更改的数据,供参考

Notes

注意事项

  • CSV files must have a header row.
  • Output is saved to a
    .diff
    file (default:
    result.diff
    ).
  • CSV文件必须包含表头行。
  • 输出结果保存到
    .diff
    文件中(默认文件名为
    result.diff
    )。

Requirements

环境要求

The
csv-diff-py
package must be installed in your environment. You can install it globally via
uv
(or user-preferred python package manager):
bash
uv tool install csv-diff-py
Alternatively, run it directly with
uvx
(or user-preferred python package runner):
bash
uvx --from csv-diff-py csvdiff file1.csv file2.csv
环境中必须安装
csv-diff-py
包。你可以通过
uv
(或你偏好的Python包管理器)全局安装它:
bash
uv tool install csv-diff-py
或者,使用
uvx
(或你偏好的Python包运行器)直接运行:
bash
uvx --from csv-diff-py csvdiff file1.csv file2.csv