commafield.

THE DATA DESK · 02

Remove duplicate rows from a CSV file

Exports from CRMs, forms and shops often repeat a record. Commafield removes the later copies, keeps the first, and shows each removed row next to the line it repeats, so you can see exactly what will disappear before you download.

Steps

  1. Open the CSV cleaner and choose Open CSV…, paste the text, or drop the file on the panel. Comma, semicolon, tab and pipe files are detected.
  2. Remove duplicate rows is on by default and compares the entire row. To find repeated customers or products, set Match duplicates by to one column, such as email or sku.
  3. Tick Ignore upper/lower case if ANA@example.com and ana@example.com should count as the same.
  4. Check the table. Removed rows are struck through and labelled Removed · repeats line N. Use Only rows with changes to see just those.
  5. Select Download cleaned CSV. The file contains every kept row, not only the 400 shown in the preview.

Worked example: one file, four settings

Download duplicates.csv. Line 1 is the header; line 5 has a space before the email address.

id,name,email,plan
101,Rae Okafor,rae@example.com,Pro
102,Jin Park,jin@example.com,Free
102,Jin Park,jin@example.com,Free
103,Ana Silva, ana@example.com,Team
104,Ana Silva,ANA@example.com,Team
105,Leo Brandt,,Pro
106,Leo B.,,Free
Match byRemovedRows outWhat happens
Entire row16Line 4 repeats line 3. Lines 5 and 6 differ in id, so both stay.
email16Line 4 again. ana@ and ANA@ differ in case. The two rows with an empty email are kept.
email + ignore case25Line 6 now repeats line 5: trimming removed the leading space, and case is ignored.
email + ignore case, trimming off16" ana@example.com" keeps its space, so it no longer matches line 6.

Trimming runs before duplicates are compared. If a match you expect is missing, look for spaces at the start or end of the cell; the marked view shows removed spaces as ·.

Matching by name also removes 2 rows here, but it would merge two different people who share a name. Prefer a column that identifies a record: an id, an email address or a SKU.

Remove duplicates from your CSV

How rows are matched

Values are compared as text: 1.0 and 1 are different, as are 2026-10-01 and 10/1/2026. Normalise such columns first if they should match.

Compared with Remove Duplicates in Excel

Excel’s Data → Remove Duplicates also keeps the first occurrence and lets you pick columns. The differences that tend to matter:

CommafieldExcel
Review before removingEach removed row is shown with the line it repeatsShows a count; removed rows are gone
CaseCase-sensitive unless you tick Ignore caseNot case-sensitive
Leading and trailing spacesTrimmed first when Trim extra spaces is onNot trimmed, so they prevent a match
Opening the fileValues stay text; leading zeros such as 001 are keptMay convert values, for example dropping leading zeros, unless you import the columns as text

The Excel behaviour is described from its documented defaults; your version and import settings may differ.

Questions

Which copy of a duplicate is kept?

The first row in the file is kept. Every later row with the same value is removed and marked with the line number it repeats, so you can check it before downloading.

Is the header row ever removed?

No. The first non-empty row is read as the header and is never compared with the data rows.

Are rows with an empty key treated as duplicates?

No. When you match by one column, rows where that column is empty are all kept, and a note says how many there were.

Can I remove duplicates without trimming spaces?

Yes. Untick Trim extra spaces. Values are then compared exactly as they are in the file, so a cell with a leading space differs from the same text without it.

Does it merge duplicate records?

No. It keeps the first row and drops the others. If two rows share an id but differ in other columns, the later values are not merged into the first row, so review those rows before you rely on the result.

Related

Files are processed in this browser tab and are not uploaded. Only your option choices are remembered. Read the privacy notice.