Remove duplicate rows from a CSV without uploading it anywhere
Why 'without uploading' matters
Free online CSV cleaners are convenient, but a customer export holds names, emails, phone numbers and sometimes addresses. Many small businesses promise clients they'll keep that private, and some workplaces forbid online converters entirely. Every method below runs on your own computer.
Before you start, save a copy of the original file and work on the copy. Then count the rows before and after, so you know exactly how many were removed.
What counts as an exact duplicate (worked example)
An exact duplicate is a row where every cell matches another row exactly. Take this small export:
- Ada Lovelace, ada@example.com, 30326
- Ada Lovelace , ada@example.com, 30326
- Ada Lovelace, ada@example.com, 30326
- ada lovelace, ada@example.com, 30326
- Ada Lovelace, ada@example.org, 30326
Without trimming, only row 3 is an exact copy of row 1. Row 2 has a stray space after the name. Trim spaces first and row 2 matches too, so rows 2 and 3 go and row 1 stays.
Row 4 differs in case and row 5 has a different email. A tool that only removes exact duplicates keeps both. That's correct: deciding whether they're the same person is a judgment call, and a human should make it.
Note that spreadsheet tools differ here. Excel's Remove Duplicates ignores case, so it would treat row 4 as a copy. Pandas and an exact-match tool keep it.
Method 1 and 2: a spreadsheet, or Python
Excel or Google Sheets
- Open the CSV. If accents look garbled, import it as UTF-8 (Excel: Data, then From Text/CSV, File Origin UTF-8).
- Trim stray spaces: in a new column, `=TRIM(A2)`, fill down, then paste as values over the original column. Repeat for each text column.
- Remove duplicates: Excel, Data, then Remove Duplicates, tick all columns. Google Sheets: Data, then Data cleanup, then Remove duplicates.
- Save as CSV UTF-8.
Watch for: spreadsheets may change leading zeros (ZIP codes), long numbers and dates when opening a CSV.
Python (pandas)
``` import pandas as pd df = pd.read_csv("customers.csv", dtype=str, keep_default_na=False) df = df.apply(lambda c: c.str.strip()) before = len(df); df = df.drop_duplicates() print(before - len(df), "duplicate rows removed") df.to_csv("customers-cleaned.csv", index=False) ```
Reading everything as text (`dtype=str`) keeps ZIP codes and phone numbers intact. To dedupe on one column, such as email, use `drop_duplicates(subset=["email"])`, but check which row is kept, because the others are dropped.
Method 3: an offline click-through tool
If you want neither formulas nor code, a local tool does the two cleanups with a record of what changed. The Local CSV Cleanup Workbench ($12) is one HTML file that runs in your browser with the internet off.
What it does:
- Imports comma, semicolon or tab files, including quoted commas, line breaks inside cells and accents
- Trims stray spaces and removes exact duplicate rows, each as its own tick box
- Shows every change in the table and a receipt (input rows, removed duplicates, output rows) before you save
- Keeps every value as text, so 001 stays 001
- Writes a new -cleaned.csv and never changes the original
- Refuses broken files and shows the line to fix, instead of guessing
- Optionally protects cells that look like spreadsheet formulas on export
Limits: UTF-8 files up to 5 MB, 20,000 rows and 200 columns. It does not do fuzzy matching ("Jon" vs "John"), case-insensitive matching, merging records or editing columns. For those, use Methods 1 or 2 with care, or your CRM's merge tool.
Checklist and common mistakes
Before:
- Save a copy of the original
- Check the delimiter (comma, semicolon or tab)
- Note the row count
After:
- Compare row counts and look at a few removed rows
- Check ZIP codes, phone numbers and dates
- Open the cleaned file before importing it anywhere
Common mistakes:
- Deduping on one column and losing rows with different details
- Letting a spreadsheet strip leading zeros
- Forgetting to trim first, so near-identical rows survive
- Expecting a duplicate remover to merge "Jon" and "John"
- Opening files from people you don't trust in a spreadsheet without looking at them first
Questions people ask
What counts as an exact duplicate?
A row where every cell matches another row exactly. Trimming spaces first makes 'Smith ' and 'Smith' match. Differences in case or spelling are not exact duplicates.
Will removing duplicates delete customers?
Only rows identical to another row. If you dedupe by email alone instead, check which row is kept, because the others are dropped.
Why do ZIP codes lose their leading zero?
Spreadsheets often read them as numbers. Import the column as text, or use a tool that keeps cells as text.
Can I find near-duplicates like Jon and John?
Not with an exact-duplicate tool. That needs a human check or a merge tool in your CRM, because only you know whether they are the same person.