Practical guide

Remove duplicate CSV rows without losing distinct records

Choose named key columns, review conflicting groups, and inspect retained and removed records.

Quick answer. Decide what identifies one record before removing duplicates. Compare complete rows when unsure. A repeated product code can describe different warehouses, and the recommended policy retains a conflicting group in full. An explicit keep-first policy removes later whole rows without merging quantities.

Try a file with a known result

Original synthetic teaching data; no customer records. Download the small sample, then load it into the matching tool. Your own files remain in your browser.

Settings for this example

Load the sample in CSV clean with Comma and a header. Leave all rules off for the baseline. Enable duplicate removal with Every column selected for full-row comparison.

Expected results to compare

  1. The baseline has 4 data records and 3 columns. Full-row comparison removes 1 duplicate, leaving 3 data records, including the South quantity 8.
  2. Restore original preview, enable duplicate removal and select only Column 1 · product_id. The recommended policy reports 1 conflicting group and removes 0 duplicates; all 4 data records stay. Explicit keep-first removes 2 records and loses the South quantity.
  3. Restore again and select product_id and warehouse as the key: 3 data records remain. Neither rule adds 12 and 8 or decides which quantity is correct.

Choose keys from your own record meaning, not from whichever option produces the fewest rows. Source record numbers include the header; a displayed removal number is not a new output row number.

Open the matching tool →

A duplicate depends on the key you choose

Two rows that look similar can describe different events. Before removing either, decide what one record represents. A repeated product code might be a duplicate in a product catalogue, but two legitimate purchases in a sales export. TableMender compares strings you choose as a key; it does not infer that business decision.

product_id,warehouse,quantity
00127,North,12
00127,South,8
00127,North,12
00904,North,3

These original teaching records have two occurrences of the same complete row. With all three columns as the key, the third data row is removed. Selecting only product_id with the recommended policy retains the entire matching group because the warehouse and quantity differ. Explicitly choosing keep-first removes both later occurrences of 00127, including the South warehouse stock. That produces fewer rows but loses a distinct quantity. A smaller result is not automatically a better result.

Use the narrowest safe rule, then inspect its effect

  1. Open CSV clean and preview the original with every cleaning rule off. Confirm the delimiter, header and number of records.
  2. Enable duplicate removal. Choose Every column to compare complete rows. To compare product and warehouse, choose Selected columns and check their numbered names after the first preview.
  3. Keep case comparison exact unless your destination treats uppercase and lowercase as equivalent. Enable trim separately only if edge whitespace is accidental.
  4. Preview again. Read the duplicate count and paginated duplicate groups. Differing fields are highlighted, and each member shows whether it was retained or removed. Download the duplicate review CSV for every member and full field values. Confirm that a removed row represents the same event as the retained one.
  5. Export All result records. Keep the original for a comparison; Restore original preview turns all cleaning rules off.

Review duplicate keys →

Keep conflicting groups unless you explicitly choose keep-first

Microsoft describes a similar first-occurrence approach for Excel's Remove Duplicates workflow: selected columns establish the match, and the later whole row is removed. TableMender keeps the first matching record when the group has no conflicting values after optional trim. By default, if any member has differing values, the entire group stays intact, including repeated copies encountered earlier. Choose keep-first explicitly only when discarding every later whole record is appropriate. It does not add quantities, combine notes, keep the newest date or prefer a nonempty field. Inspect conflicting groups and resolve their values in your source, or keep them for later review. Empty identifiers in a selected partial key are excluded from duplicate removal under either policy.

TableMender compares parsed field strings, whereas a spreadsheet may compare displayed or typed values. Here 00127 and 127 are different keys. Optional ignore case uses JavaScript lowercase conversion, without changing the exported spelling. It is not a locale-aware identity rule, and does not equate every linguistic variant.

Filtering changes the view; cleaning changes the result

Searching for North shows matching records but does not remove South from the result. The export selector controls whether you download every result record or every match across all preview pages. Duplicate removal, by contrast, changes the result before filtering. Always compare the result count, matching count and export count rather than judging a single page.

The header stays outside duplicate comparison. When a file has no header, turn that setting off so its first data record is eligible for cleaning and export. The column picker includes one-based numbers alongside names; blank and repeated header labels remain distinguishable. Case-insensitive comparison applies only to the chosen key columns. Other fields with different letter case still create a conflict.

Keep malformed records visible

Nonempty records with inconsistent field counts remain in the preview and block export. A missing key is not treated as a duplicate of an empty key. An entirely empty physical record can be removed only with the separate empty-record rule. Quoted line breaks are field contents, not extra duplicate records. TableMender does not pad missing fields or silently discard surplus ones.

Edge cases and boundary cases

Case-insensitive keys treat North and north as the same key string for comparison, but the export still keeps the original spelling of the retained row. That is not a locale-aware fold: characters that lowercase differently across languages may still disagree.

Empty values inside a selected partial key exclude that record from duplicate removal under either policy. They are not treated as matching every other empty key. Fill or map identifiers in the source before you decide two blank codes are the same entity.

Full-row deduplication after a bad Excel Save As can remove rows that only look identical because truncated IDs already collided. Inspect keys character-for-character first. If tracking numbers show exponents, re-export rather than dedupe—see Excel Save As CSV pitfalls.

Conflicting groups with different quantities are retained by default on purpose. Keep-first is irreversible for discarded later rows in the current preview; use Restore original preview if the removal was wrong. Neither policy merges fields or adds quantities across warehouses.

Before stacking extracts and then deduplicating, run the checks in Check CSV files before you merge them. A second header sitting in the data is not a duplicate of a product row.

Before and after: same file, three keys

Download /samples/duplicate-keys.csv and open it in CSV clean with Comma and a header. Leave every rule off for the baseline. The teaching file has 4 data records and 3 columns:

product_id,warehouse,quantity
00127,North,12
00127,South,8
00127,North,12
00904,North,3

The third data row is an exact copy of the first. South quantity 8 is a different record that happens to share the product code. Those two facts need different keys.

duplicate-keys.csv under each duplicate rule in CSV clean
Rule after PreviewData records leftWhat the result still contains
Every rule off4Both North/12 copies, South/8, and 00904
Duplicate removal, Every column3One North/12, South/8, and 00904. One exact copy is removed
product_id only, keep conflicts (default)4The whole 00127 group stays, because warehouse and quantity differ. 0 rows removed, 1 conflicting group
product_id only, explicit keep-first2The first 00127 North/12 and 00904. South quantity 8 is discarded

Compare Original parse with Result. Changed cells are highlighted on the result view. A cleaned download uses a -cleaned suffix and does not replace the sample. The duplicate-review CSV (-duplicate-review.csv) lists group members; it is not the cleaned data file. Product code 00127 is still text here. If you later need a workbook, open CSV to Excel on the cleaned file and leave that column on Text.

Step-by-step troubleshooting

  1. The row count fell further than the repeated North row. Keep-first or a product-only key is on. Restore original preview, return to the default conflict policy, and preview again before you download.
  2. Two rows look the same and nothing was removed. A field still differs, including edge spaces or letter case. Trim and ignore-case are separate switches. 00127 and 127 are different keys.
  3. A blank product code did not join a group. An empty value in a selected partial key is excluded from duplicate removal under either policy. Map that identifier in the source if two blank codes should match.
  4. Download stays blocked. Uneven nonempty records are not duplicates. Fix the width in CSV check & repair. This cleaner does not pad or drop fields to force a match.
  5. You expected 12 and 8 to become 20. Neither policy adds quantities or merges notes. Resolve that in the system that owns the stock figures.

Honest limits

CSV clean does not know which warehouse is canonical, which row is newest, or which note should survive. It will not open an Excel workbook and it will not replay Excel’s Remove Duplicates button. A file that already lost digits can make distinct shipments look identical; removing those rows hides the collision instead of fixing it. Read Excel Save As CSV pitfalls and Repair versus re-export before you dedupe a round-trip export. The local preflight summary’s whole-row duplicate line is only a hint. Named keys on this page are the real decision.

Fewer rows is not a successful clean. Keep a conflicting group until you can name the row you are willing to lose.

Sources:

Examples are original teaching data. Tool-specific behavior describes this version of TableMender; software interfaces can vary by version.

← All guides