Cleaning a CSV export before you import it anywhere
The usual defects of a CSV export, fixed in the order that avoids rework: an eight-row orders file taken through four tools, with rows before and after.
A CSV export is rarely ready to import somewhere else. The system that produced it had its own ideas about date formats, header names and empty fields, and the system you are importing into has different ones. The defects are predictable, so the fixes can follow a fixed order. This guide takes the usual problems in the order that avoids redoing work, names the tool for each, and ends with an eight-row orders export taken through four fixes, with the actual rows before and after. Every tool here runs inside the browser tab, so the export itself stays on your computer.
Look before you fix anything
Open the file in CSV Viewer first. It renders the rows as a table, which is enough to spot a repeated order id, a blank cell, or a date column where half the values use slashes and the other half dashes. Then run CSV Column Type Detector on the same file. It checks every value in each column and reports whether at least 80% parse as a number, a date or a boolean, with three sample values beside each verdict. On the orders export below it reported Order ID and Amount as numbers at 100% (values with a thousands separator such as 1,250.00 count as numbers) and Order Date as text, because the formats were mixed. That verdict is the to-do list. A column holding only 0 and 1 is reported as a number; only true, false, yes and no count as boolean.
The order that avoids rework
- Get the file into comma-separated form.
- Remove duplicate rows.
- Fill or remove blank cells.
- Normalise the date columns.
- Check numeric columns for values stored as text.
- Rename and reorder the headers to match the target.
- Decide about the byte-order mark last.
Duplicates go before blanks because the duplicate remover compares one key column, and every row with an empty key looks identical to it: they all collapse into one. Dates go before headers because the date tool picks the column by its current name. The byte-order mark goes last because several tools add one on output, so removing it halfway through is wasted effort.
Wrong delimiter
Systems set to European locales often export with semicolons, and data copied out of a spreadsheet arrives tab-separated. CSV Delimiter Converter takes a file or pasted text, detects the delimiter from the first line when set to auto, and writes the rows out with the delimiter you choose. When the output delimiter is a comma, any value containing a comma is wrapped in quotes, so a semicolon file with decimal commas comes out as:
order_id,customer_email,region,amount,order_date 1001,ann.lee@example.com,East,"1250,00",2026-01-04
The quoting is correct, but "1250,00" is still a decimal-comma value that most importers read as text; that is a separate fix, covered under numbers. The download is named converted.csv, or converted.tsv when the output is tab-separated, and any value that contains the new delimiter is quoted rather than altered. For tab-separated text pasted from a spreadsheet, TSV & CSV Converter converts in either direction and works on pasted text only.
Duplicate rows
CSV Duplicate Remover lists the headers in a drop-down; you choose the key column and whether to keep the first or last occurrence of each key. The comparison is an exact string match on that one column, so 1002 with a trailing space is a different key from 1002, and Paid differs from paid. Rows come back in their original order and the result line reads 8 → 7 rows, a quick check against what you expected to lose. If the export has no natural key such as an order id, this is not the right tool: rows that are identical in every column usually mean an export run twice, and the fix is to re-export.
Blank cells
CSV Missing Value Cleaner has two modes. Remove rows with blanks drops any row with at least one empty cell in any column. Fill blank cells writes the text you supply, N/A by default, into every empty cell. There is no per-column setting, so pick the fill value with every column in mind: N/A in an amount column turns it into text. On the seven-row file below, fill mode kept all seven rows; remove mode would have kept six.
Mixed date formats
CSV Date Normalizer rewrites one column into YYYY-MM-DD, YYYY/MM/DD, MM/DD/YYYY or DD/MM/YYYY. Before trusting it, know how it reads the input. A value starting with a four-digit year is read year first. A value with the year last is read day first only when the first number is greater than 12; otherwise month first. Anything else goes to the browser's date parser, which copes with Jan 6, 2026 and 6 January 2026. Unreadable values are kept or blanked, depending on the setting. A test column shows the consequences:
| Input | Output (YYYY-MM-DD) | Why |
|---|---|---|
| 15/01/2026 | 2026-01-15 | 15 cannot be a month, so day first |
| 04/01/2026 | 2026-04-01 | Ambiguous, read as month first |
| 06.01.2026 | 2026-06-01 | Same rule: a European 6 January becomes 1 June |
| Jan 6, 2026 | 2026-01-06 | Parsed by the browser |
| 2026-1-5 | 2026-01-05 | Padded with zeros |
| 20260107 | 20260107 | Not recognised, kept as is |
| TBD | TBD | Not recognised, kept as is |
So if the export is day-first and contains days of 12 or lower, the tool swaps day and month on those rows without warning. Check the source system's convention first, and if it is day-first, confirm a few rows in the viewer afterwards. Rows kept as is are easy to find later with the row filter: contains a slash on the date column.
Numbers stored as text
The usual causes are thousands separators, currency symbols and decimal commas. CSV Column Statistics shows what an importer will see: it strips commas before converting, so on the Amount column of the orders file it counts 8 numeric values, sum 4507.2000, minimum 45, maximum 2040. Empty cells are not converted: they are left out of the count, sum, average, minimum and maximum and reported in the empty counter instead, so read that counter alongside the sum. CSV Row Filter uses the same conversion for its greater than and less than rules; Amount greater than 300 returned 4 rows, including 1,250.00 and 2,040.00. Its text rules ignore case unless you tick the case box. None of these tools rewrites the number format itself; for that, use a spreadsheet or a find-and-replace on the separator, then re-run the detector.
Headers that do not match the target
Import templates are strict about header spelling. CSV Column Renamer pre-fills a mapping box with one Old:New line per header, both sides identical, so you edit only the right-hand side of the lines you want to change. The match on the left is exact, including case and trailing spaces, and only the header row changes. CSV Column Reorder pre-fills a comma-separated list of the current headers; rearrange it and process. Any header left out of the list is dropped from the output, which makes the tool double as a column remover, and a name that does not match exactly stops the run with Check the column names. Run the renamer first and use the new names in the reorder list.
Byte-order mark and encoding
Some systems write a UTF-8 byte-order mark, three bytes at the start of the file, so that Excel recognises the encoding; others reject a file that has one, typically by failing to match the first header. The tools here do not mind either way: the browser strips the mark while reading, so Order ID is a clean column name in every drop-down. Output varies, though. The duplicate remover, missing-value cleaner and row filter write UTF-8 without a mark; the date normalizer, column renamer, column reorder and delimiter converter add one. UTF-8 BOM Tool reports UTF-8 BOM present or No UTF-8 BOM detected as soon as you choose a file and downloads a copy with the mark added or removed, prefixed bom- or no-bom-. Run it once, at the end, in whichever direction the target needs. A legacy encoding such as Windows-1252 is a different problem: accented names show as garbled characters in the viewer, and the fix is to re-export as UTF-8 at the source.
Walkthrough: an eight-row orders export
The export below came out of an order system as orders-export.csv. It has a duplicated row (order 1002 appears twice), a blank region on order 1003, four date formats in one column, two amounts with thousands separators, and headers with spaces and capitals that the target, which expects snake_case, will not accept.
Order ID,Customer Email,Region,Amount,Order Date,Status 1001,ann.lee@example.com,East,"1,250.00",2026-01-04,paid 1002,ben.ortiz@example.com,West,89.90,15/01/2026,paid 1002,ben.ortiz@example.com,West,89.90,15/01/2026,paid 1003,chloe.park@example.com,,312.40,"Jan 6, 2026",pending 1004,dev.patel@example.com,North,45.00,2026/01/06,refunded 1005,emma.rossi@example.com,East,560.00,2026-01-07,paid 1006,felix.wu@example.com,West,120.00,2026-01-08,pending 1007,ann.lee@example.com,East,"2,040.00",2026-01-08,paid
Fix 1, duplicates. Duplicate remover, key column Order ID, keep first. The status reads 8 rows on load and 8 → 7 rows after processing. The download is deduplicated.csv; the second 1002 row is gone and nothing else has changed.
Fix 2, blank cells. Load deduplicated.csv into the missing-value cleaner, mode Fill blank cells, fill text Unassigned. Status: 7 rows ready. The download, cleaned.csv, has Unassigned as the region of order 1003. In remove mode the status would have read 6 rows ready. and order 1003 would be gone.
Fix 3, dates. Load cleaned.csv into the date normalizer, column Order Date, format YYYY-MM-DD, invalid values kept. The download is cleaned-dates.csv: 15/01/2026 became 2026-01-15, Jan 6, 2026 and 2026/01/06 both became 2026-01-06, and the ISO values are unchanged. This file carries a byte-order mark.
Fix 4, headers. Load cleaned-dates.csv into the column renamer. The mapping box shows six lines such as Order ID:Order ID; change the right-hand sides to order_id, customer_email, region, amount, order_date and status. The download is cleaned-dates-renamed.csv:
order_id,customer_email,region,amount,order_date,status 1001,ann.lee@example.com,East,"1,250.00",2026-01-04,paid 1002,ben.ortiz@example.com,West,89.90,2026-01-15,paid 1003,chloe.park@example.com,Unassigned,312.40,2026-01-06,pending 1004,dev.patel@example.com,North,45.00,2026-01-06,refunded 1005,emma.rossi@example.com,East,560.00,2026-01-07,paid 1006,felix.wu@example.com,West,120.00,2026-01-08,pending 1007,ann.lee@example.com,East,"2,040.00",2026-01-08,paid
Seven rows, one date format, headers the target accepts. Two things remain, both deliberate. The amounts 1,250.00 and 2,040.00 still carry thousands separators; the type detector reports amount as a number at 100% (and order_date as a date at 100% now that the formats agree), but an importer that does not strip commas will still read those two values as text. And the file has a byte-order mark from the date and rename steps; if the target rejects it, the BOM tool removes it. If the target also wants a different column order, say the date second and no region, the reorder tool with the list order_id, order_date, customer_email, amount, status produces exactly that: five columns, region dropped.
Before you import
- Open the final file in the viewer and read every row; a wrong month on a date is easier to see than to detect.
- Run the type detector again. Date columns should now report
date; anything still reported as text in a numeric column needs the separator fix. - Keep the original export. Every tool writes a new file under a different name, so the chain can be re-run from any step.
- If the target allows it, import a two-row copy first; header rejection and date misreads show up immediately.
CSV 匯出檔的常見缺陷與不必返工的修正順序,並以一份八列訂單檔實際跑過四個工具,附修正前後的資料列。
匯出的 CSV 很少能直接匯入別的系統。產生檔案的系統對日期格式、欄位名稱與空白欄位有自己的一套,而你要匯入的系統又是另一套。這些缺陷都有固定模式,所以修法也能照固定順序來。本文依照不必返工的順序處理常見問題,為每一項指出對應的工具,最後用一份八列的訂單匯出檔實際跑過四個修正步驟,附上修正前後的實際資料列。這裡的每個工具都在瀏覽器分頁內執行,匯出檔本身一直留在你的電腦上。
動手之前先看一遍
先用 CSV 檢視器開啟檔案。它把資料列畫成表格,足以看出重複的訂單編號、空白儲存格,或是同一個日期欄位裡一半用斜線、一半用連字號的情況。接著用 CSV 欄位類型偵測跑同一個檔案。它會檢查每一欄的所有值,判斷是否有至少 80% 能解析成數字、日期或布林值,並在每個判定旁列出三個範例值。在下面的訂單匯出檔上,它把 Order ID 與 Amount 都判為數字(100%),1,250.00 這類帶千分位符號的值也算數字;Order Date 則判為文字,因為格式混雜。這個判定就是待辦清單。只含 0 與 1 的欄位會被判為數字;只有 true、false、yes、no 才算布林值。
不必返工的順序
- 先把檔案轉成逗號分隔。
- 移除重複列。
- 填入或移除空白儲存格。
- 統一日期欄位的格式。
- 檢查數值欄位是否有被存成文字的值。
- 把欄位名稱與順序改成目標系統要的樣子。
- 最後才決定位元組順序記號(BOM)。
重複列要排在空白之前,因為重複資料移除工具只比對一個鍵值欄位,所有鍵值空白的列在它看來完全相同,會全部壓成一列。日期要排在欄位名稱之前,因為日期工具是用目前的欄位名稱選欄。BOM 放最後,因為有幾個工具輸出時會自己加上一個,中途移除是白費工夫。
分隔符不對
設定成歐洲地區格式的系統常以分號匯出,從試算表複製出來的資料則是以 Tab 分隔。CSV 分隔符轉換可接受檔案或貼上的文字,設為自動時依第一行偵測分隔符,再用你選的分隔符寫出各列。輸出分隔符是逗號時,含逗號的值會被加上引號,所以一個使用小數逗號的分號檔會變成:
order_id,customer_email,region,amount,order_date 1001,ann.lee@example.com,East,"1250,00",2026-01-04
引號加得沒錯,但 "1250,00" 仍是小數逗號的值,多數匯入程式會把它當成文字;這是另一個問題,在「數字被存成文字」一節處理。下載檔名是 converted.csv(輸出為 Tab 分隔時是 converted.tsv),含有新分隔符號的值會加上引號,內容不會被更動。從試算表貼出來的 Tab 分隔文字,可用 TSV 與 CSV 互轉雙向轉換,它只處理貼上的文字。
重複列
CSV 重複資料移除會把欄位名稱放進下拉選單,由你選擇鍵值欄位,並決定每個鍵值保留第一次或最後一次出現的列。比對是對該欄做精確字串比對,所以尾端多一個空格的 1002 和 1002 是不同鍵值,Paid 和 paid 也不同。輸出維持原本的列順序,結果列顯示 8 → 7 rows,可以快速核對是否和預期要去掉的數量一致。若匯出檔沒有訂單編號這類天然鍵值,這個工具就不適用:每一欄都相同的列通常代表匯出跑了兩次,正確的修法是重新匯出。
空白儲存格
CSV 缺失值清理有兩種模式。移除含空白的列會刪掉任何一欄有空白儲存格的列。填入空白儲存格會把你提供的文字(預設 N/A)寫進每一個空白儲存格。沒有逐欄設定,所以選填入值時要把每一欄都考慮進去:金額欄填成 N/A 就變成文字欄。在下面那份七列的檔案上,填入模式保留了全部七列;移除模式只會剩六列。
日期格式混雜
CSV 日期格式統一會把一個欄位改寫成 YYYY-MM-DD、YYYY/MM/DD、MM/DD/YYYY 或 DD/MM/YYYY。信任它之前,先了解它怎麼讀輸入值。以四位數年份開頭的值以年份優先解讀。年份在最後的值,只有在第一個數字大於 12 時才以日優先解讀,否則一律月優先。其他格式交給瀏覽器的日期解析器,它能處理 Jan 6, 2026 與 6 January 2026。無法辨識的值依設定保留原樣或清空。用一個測試欄位跑過,結果如下:
| 輸入 | 輸出(YYYY-MM-DD) | 原因 |
|---|---|---|
| 15/01/2026 | 2026-01-15 | 15 不可能是月份,所以日優先 |
| 04/01/2026 | 2026-04-01 | 有歧義,以月優先解讀 |
| 06.01.2026 | 2026-06-01 | 同一規則:歐式寫法的 1 月 6 日變成 6 月 1 日 |
| Jan 6, 2026 | 2026-01-06 | 由瀏覽器解析 |
| 2026-1-5 | 2026-01-05 | 補零 |
| 20260107 | 20260107 | 無法辨識,保留原樣 |
| TBD | TBD | 無法辨識,保留原樣 |
因此若匯出檔是日優先,且含有日數在 12 以下的日期,工具會不作任何提示地把那些列的日與月對調。先確認來源系統的慣例;若是日優先,跑完後在檢視器裡核對幾列。保留原樣的列事後很容易用資料篩選找出來:對日期欄用包含加一個斜線即可。
數字被存成文字
常見原因是千分位符號、貨幣符號與小數逗號。CSV 欄位統計能顯示匯入程式會看到什麼:它在轉換前先去掉逗號,所以在訂單檔的 Amount 欄上數到 8 個數值,總和 4507.2000、最小值 45、最大值 2040。空白儲存格不會被轉換:它們不計入計數、總和、平均、最小值與最大值,而是另外記在空值計數裡,所以看總和時要連空值計數一起看。CSV 資料篩選的大於與小於規則用的是同一套轉換;以 Amount 大於 300 篩選得到 4 列,包含 1,250.00 與 2,040.00。它的文字規則預設不分大小寫,除非勾選區分大小寫。這些工具都不會改寫數字格式本身;要改的話,用試算表或對分隔符號做尋找取代,再重跑一次偵測。
欄位名稱與目標不符
匯入範本對欄位名稱的拼法很嚴格。CSV 欄位批量改名會預先在對應框裡為每個欄位填一行 舊名:新名,兩邊相同,所以你只需改想變更那幾行的右半邊。左邊的比對是精確比對,包含大小寫與尾端空格,而且只有標題列會改變。CSV 欄位重新排序會預填一串以逗號分隔的目前欄位名稱,重新排列後執行即可。清單裡漏掉的欄位會從輸出中被移除,所以這個工具也兼作刪欄工具;而不完全相符的名字會讓執行中止並顯示 Check the column names.。先跑改名工具,再在排序清單裡用新名稱。
BOM 與編碼
有些系統會在檔案開頭寫入 UTF-8 位元組順序記號(三個位元組),好讓 Excel 認出編碼;另一些系統則會拒絕帶有它的檔案,通常表現為第一個欄位名稱比對失敗。這裡的工具兩種情況都無所謂:瀏覽器讀取時會去掉這個記號,所以 Order ID 在每個下拉選單裡都是乾淨的欄位名稱。但輸出端各有不同。重複資料移除、缺失值清理與資料篩選寫出的是不帶記號的 UTF-8;日期格式統一、欄位批量改名、欄位重新排序與分隔符轉換則會加上一個。UTF-8 BOM 工具在你選檔後立刻顯示 UTF-8 BOM present 或 No UTF-8 BOM detected,並可下載加上或移除記號的副本,檔名前綴為 bom- 或 no-bom-。在最後跑一次,方向依目標系統的需求而定。Windows-1252 這類舊編碼是另一個問題:帶重音符號的名字在檢視器裡會顯示成亂碼,解法是在來源端重新以 UTF-8 匯出。
實作:八列的訂單匯出檔
下面這份匯出檔來自訂單系統,檔名 orders-export.csv。它有一列重複(訂單 1002 出現兩次)、訂單 1003 的地區空白、同一欄裡有四種日期格式、兩個帶千分位符號的金額,以及含空格與大寫的欄位名稱,而要求 snake_case 的目標系統不會接受這些名稱。
Order ID,Customer Email,Region,Amount,Order Date,Status 1001,ann.lee@example.com,East,"1,250.00",2026-01-04,paid 1002,ben.ortiz@example.com,West,89.90,15/01/2026,paid 1002,ben.ortiz@example.com,West,89.90,15/01/2026,paid 1003,chloe.park@example.com,,312.40,"Jan 6, 2026",pending 1004,dev.patel@example.com,North,45.00,2026/01/06,refunded 1005,emma.rossi@example.com,East,560.00,2026-01-07,paid 1006,felix.wu@example.com,West,120.00,2026-01-08,pending 1007,ann.lee@example.com,East,"2,040.00",2026-01-08,paid
修正 1:重複列。重複資料移除,鍵值欄位 Order ID,保留第一次出現。載入時狀態顯示 8 rows,處理後顯示 8 → 7 rows。下載檔為 deduplicated.csv;第二列 1002 不見了,其他都沒變。
修正 2:空白儲存格。把 deduplicated.csv 載入缺失值清理,模式選填入空白儲存格,填入文字 Unassigned。狀態:7 rows ready.。下載檔 cleaned.csv 裡,訂單 1003 的地區成了 Unassigned。若用移除模式,狀態會顯示 6 rows ready.,訂單 1003 會消失。
修正 3:日期。把 cleaned.csv 載入日期格式統一,欄位 Order Date,格式 YYYY-MM-DD,無效值保留。下載檔為 cleaned-dates.csv:15/01/2026 變成 2026-01-15,Jan 6, 2026 與 2026/01/06 都變成 2026-01-06,ISO 格式的值不變。這個檔案帶有 BOM。
修正 4:欄位名稱。把 cleaned-dates.csv 載入欄位批量改名。對應框顯示六行,例如 Order ID:Order ID;把右半邊改成 order_id、customer_email、region、amount、order_date 與 status。下載檔為 cleaned-dates-renamed.csv:
order_id,customer_email,region,amount,order_date,status 1001,ann.lee@example.com,East,"1,250.00",2026-01-04,paid 1002,ben.ortiz@example.com,West,89.90,2026-01-15,paid 1003,chloe.park@example.com,Unassigned,312.40,2026-01-06,pending 1004,dev.patel@example.com,North,45.00,2026-01-06,refunded 1005,emma.rossi@example.com,East,560.00,2026-01-07,paid 1006,felix.wu@example.com,West,120.00,2026-01-08,pending 1007,ann.lee@example.com,East,"2,040.00",2026-01-08,paid
七列、一種日期格式、目標系統接受的欄位名稱。還剩兩件事,都是刻意留下的。金額 1,250.00 與 2,040.00 仍帶千分位符號;類型偵測把 amount 判為數字(100%),格式統一後 order_date 也判為日期(100%),但不會去掉逗號的匯入程式仍會把這兩個值讀成文字。另外,檔案因為日期與改名兩個步驟而帶有 BOM;若目標系統拒收,用 BOM 工具移除。若目標系統還要求不同的欄位順序,例如日期放第二欄且不要地區欄,用欄位重新排序搭配清單 order_id, order_date, customer_email, amount, status 就能得到正好五欄、地區已移除的結果。
匯入之前
- 用檢視器開啟最終檔案,逐列讀過;日期的月份錯了用眼睛看比用程式偵測容易。
- 再跑一次類型偵測。日期欄現在應該報為
date;數值欄裡還被報為文字的值就需要處理分隔符號。 - 保留原始匯出檔。每個工具都會以不同檔名寫出新檔,整條流程可以從任何一步重跑。
- 若目標系統允許,先匯入只有兩列的副本;欄位名稱被拒與日期誤讀會立刻浮現。