≠

CSV File Difference

Compare two CSV files by a key column and export differences

No file selected.
0Added rows
0Removed rows
0Changed rows

CSV File Difference — what it does

Compare two CSV files on a shared key column and get three lists: rows added in the second file, rows removed from the first, and rows whose values changed. The report can be downloaded, which turns an ad-hoc comparison into something you can attach to a ticket or an audit trail.

Worked example

Two versions of a price list compared on sku. Only headers present in both files are offered as the key; sku was selected.

Input — prices-v1.csv and prices-v2.csv

prices-v1.csv
sku,product,price
A-100,Notebook,3.50
A-101,Stapler,8.99
A-103,Desk lamp,24.00

prices-v2.csv
sku,product,price
A-100,Notebook A5,3.75
A-101,Stapler,8.99
A-105,Monitor stand,45.00

Output — csv-difference-report.csv

key,status,details
A-105,added,A-105 | Monitor stand | 45.00
A-103,removed,A-103 | Desk lamp | 24.00
A-100,changed,product: Notebook => Notebook A5; price: 3.50 => 3.75

The counters show Added 1, Removed 1, Changed 1. An added or removed row is written whole with vertical bars between cells; a changed row lists only the columns that differ, as column: old => new separated by semicolons (sku and the unchanged A-101 row do not appear). The download starts with a UTF-8 byte-order mark.

When this tool helps

  • Checking what a nightly export actually changed since yesterday's copy before loading it into a system.
  • Verifying that a bulk edit changed only the records it was supposed to change.
  • Reconciling a supplier price list against the version you currently have loaded.

How to use it

  1. Load the first CSV and then the second.
  2. Select the key column that identifies a row in both files.
  3. Process the comparison.
  4. Review added, removed and changed counts, then download the report.

Accuracy, limits, and good practice

  • The key must be unique in both files. Duplicated keys make row-to-row matching ambiguous and the results unreliable.
  • Column order does not matter, but column names do — a renamed header, or a column that exists in only one file, makes every matched row count as changed.
  • Formatting-only differences such as 1000 versus 1,000 register as changes; normalise numbers and dates first for a meaningful diff.

Frequently asked questions

What if the two files have different columns?

Rows are matched on your chosen key and compared across every column name in either file, so a column present in only one file makes each matched row count as changed. Align the schemas first with the column extractor for a clean result.

Can it compare files with no key column?

Not reliably. Without a key, there is no way to know which row in one file corresponds to which row in the other.

Does it detect reordered rows as changes?

No. Matching is by key, not by position, so reordering the same data produces no differences at all.

Does column order matter when the two files are compared?

No. Matched rows are compared by column name. With the second file saved as price,sku,product (and the original Notebook name), the result is still Added 1, Removed 1, Changed 1, and the A-100 details read price: 3.50 => 3.75. Only the whole-row text of an added or removed row follows its own file's column order: 45.00 | A-105 | Monitor stand.

What if a key value appears twice in the same file?

The last row with that key is the one compared, and the status line says so: adding a second A-101 row priced 9.49 to prices-v2.csv shows "Done. 1 duplicate key(s): the last row with each key was compared." and reports A-101 as changed with price: 8.99 => 9.49. Deduplicate on the key first if the earlier row is the one you meant.

Related tools on this site

Everything above runs inside this page. CSV File Difference needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

CSV 檔案差異比較能做什麼

以共同的鍵值欄位比較兩份 CSV,並產出三份清單:第二份新增的列、第一份被移除的列,以及值有變動的列。報告可下載,讓臨時的比對變成能附在工單或稽核紀錄上的文件。

實際範例

兩個版本的價目表以 sku 比對。只有兩檔都有的欄名才會列在鍵欄位清單裡,這裡選 sku。

來源:prices-v1.csv 與 prices-v2.csv

prices-v1.csv
sku,product,price
A-100,Notebook,3.50
A-101,Stapler,8.99
A-103,Desk lamp,24.00

prices-v2.csv
sku,product,price
A-100,Notebook A5,3.75
A-101,Stapler,8.99
A-105,Monitor stand,45.00

得到:csv-difference-report.csv

key,status,details
A-105,added,A-105 | Monitor stand | 45.00
A-103,removed,A-103 | Desk lamp | 24.00
A-100,changed,product: Notebook => Notebook A5; price: 3.50 => 3.75

計數器顯示新增 1、移走 1、變更 1。新增與移走的列會整列寫出,儲存格之間以直線分隔;變更的列只列出不同的欄位,格式為「欄名: 舊值 => 新值」,以分號隔開(sku 與沒變的 A-101 不會出現)。下載檔開頭帶 UTF-8 BOM。

什麼時候用得上

  • 在把每日匯出檔載入系統前,確認它相對昨天的版本到底改了什麼。
  • 驗證批次修改是否只動到預期範圍內的紀錄。
  • 把供應商新的價格表與目前使用的版本核對。

使用步驟

  1. 先載入第一份 CSV,再載入第二份。
  2. 選定兩邊都能識別同一列的鍵值欄位。
  3. 執行比較。
  4. 檢視新增、移除與變更筆數,再下載報告。

精確度、限制與實務建議

  • 鍵值在兩份檔案中都必須唯一,鍵值重複會讓逐列比對出現歧義,結果不可信。
  • 欄位順序不影響比較,但欄位名稱會:標題被改名,或某欄只存在於其中一個檔案,每一筆配對到的列都會被算成變更。
  • 純格式差異(如 1000 與 1,000)也會被視為變更,建議先統一數字與日期格式再比對。

常見問題

兩份檔案欄位不同怎麼辦?

列會依你選的鍵值配對,再就兩份檔案出現過的所有欄名比較,所以只有一邊才有的欄位會讓每一筆配對到的列都算成變更。建議先用欄位提取工具讓兩邊結構一致,結果才乾淨。

沒有鍵值欄位可以比嗎?

無法可靠比較。沒有鍵值就無從得知一邊的某列對應另一邊的哪一列。

資料列順序調換會被當成變更嗎?

不會。比對依鍵值而非位置,同樣的資料換順序不會產生任何差異。

比對時欄位順序有影響嗎?

沒有。配對到的列是依欄名比對的。把第二個檔案存成 price,sku,product 的順序(品名維持 Notebook),結果仍是新增 1、移走 1、變更 1,A-100 的 details 是 price: 3.50 => 3.75。只有新增或移走的整列文字依各自檔案的欄位順序排列:45.00 | A-105 | Monitor stand。

同一個檔案裡鍵值重複會怎樣?

以該鍵的最後一列做比對,狀態列也會說明:在 prices-v2.csv 再加一列售價 9.49 的 A-101,會顯示「Done. 1 duplicate key(s): the last row with each key was compared.」,並把 A-101 報成變更,details 為 price: 8.99 => 9.49。若你要的是前面那一列,請先以鍵欄位去重。

本站相關工具

以上步驟全部在這個頁面內完成,CSV 檔案差異比較 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。