How to standardize inconsistent phone number formats in a CSV
Why '(555) 123-4567', '555-123-4567', and '5551234567' look like different values to a computer, and how to normalize them for matching without losing the original.
Before you work through this by hand: you can check your own CSV free and see which of these problems your file actually has — duplicate rows, near-duplicates, broken quoting, encoding damage. It runs in your browser tab, nothing is uploaded, and there's no signup or email.
Why phone numbers vary so much
Phone numbers get entered with parentheses, dashes, dots, spaces, a leading "+1" or "1", or no punctuation at all — often several different formats within the same file if it was compiled from multiple sources. Every one of those looks like a distinct value to an exact-match comparison.
A basic normalization approach
import re; digits_only = re.sub(r'\D', '', phone_value) strips everything except digits, turning "(555) 123-4567" and "555-123-4567" into the same "5551234567". This is usually enough for US-style numbers within one country.
The country-code trap
Stripping to digits-only doesn't fix a number that sometimes includes a country code and sometimes doesn't — "15551234567" (with a leading 1) and "5551234567" (without it) are the same phone number but still won't match as equal strings after a naive digit-strip. Decide on a consistent rule (e.g. always strip a leading "1" if the rest is 10 digits) rather than assuming raw digit comparison is enough.
International numbers need a real library, not regex
If your data includes phone numbers from more than one country, format rules vary enough (number length, area code structure) that a regex-only approach will misparse some of them. Python's phonenumbers library (a port of Google's libphonenumber) parses and normalizes international numbers correctly and is worth installing rather than hand-rolling international rules.
Same rule as other normalization guides
As with normalizing case: keep the original formatted phone number for display, and use the normalized digits-only version only as the internal key for matching and deduplication.
See CSV Repair & Deduper (offline browser tool) — $19 one-time