Every directory built from a Google Maps export eventually runs into the same mess. The phone column has numbers in four formats. The website column mixes bare domains, full URLs with tracking parameters, links to Facebook pages and the occasional booking widget. None of it breaks the build, but it breaks things downstream: duplicate detection misses obvious matches, tel: links fail on some phones, and a "has website" filter counts a social profile as a website.
This post covers a small normalization pass for those two columns, the kind you run once after each export and before generating pages. The examples are Python, but the rules carry over to any language.
Why normalize at all
Exports from Outscraper, Apify or any scraper come from the text businesses typed into their profiles, plus whatever formatting the tool applies. Two exports of the same business a month apart can return the same phone number as (212) 736-5000 and +1 212-736-5000. Compare them as strings and you get two different values.
Normalizing gives you one canonical form for comparison and storage, and you can still format it nicely for display. Keep the raw value too. When something looks wrong later, you'll want to see what the export actually said.
The code
Hand-rolled regex for phone numbers works until it meets a country code, an extension or a vanity number with letters. The phonenumbers package, a Python port of Google's libphonenumber, handles those cases. Parse with a default region that matches your directory, check validity and store the E.164 form. URLs only need the standard library.
import phonenumbers from urllib.parse import urlsplit, urlunsplit, parse_qsl, urlencode def norm_phone(raw, region="US"): try: n = phonenumbers.parse(raw or "", region) except phonenumbers.NumberParseException: return None if not phonenumbers.is_valid_number(n): return None return phonenumbers.format_number(n, phonenumbers.PhoneNumberFormat.E164) SOCIAL = ("facebook.com", "instagram.com", "yelp.com") TRACKING = {"utm_source", "utm_medium", "utm_campaign", "fbclid", "gclid"} def norm_url(raw): if not raw or not raw.strip(): return None, None raw = raw.strip() if "://" not in raw: raw = "https://" + raw p = urlsplit(raw) host = p.netloc.lower().removeprefix("www.") query = urlencode([(k, v) for k, v in parse_qsl(p.query) if k not in TRACKING]) url = urlunsplit((p.scheme.lower(), host, p.path.rstrip("/"), query, "")) kind = "social" if host.endswith(SOCIAL) else "site" return url, kind Phone numbers: parse, validate, store E.164
norm_phone returns None for anything that doesn't parse or isn't a valid number, and lets the template decide what to show. A card with no phone should switch its main action to the website or a contact form, not print a broken number.
For display, format the stored value with PhoneNumberFormat.NATIONAL for local visitors. Use the E.164 form inside tel: links, since it behaves the same on every phone.
Websites: clean, classify, keep the raw value
The website column needs less parsing and more judgment. norm_url does four things:
- Adds a scheme when the export has a bare domain.
- Lowercases the host and drops a leading
www.so comparisons line up. - Removes common tracking parameters but keeps the rest of the query string, because some booking links need it.
- Labels the result as a site or a social profile.
That last step matters more than it looks. Plenty of small businesses list a Facebook or Instagram page as their website. Showing it as "Website" sets the wrong expectation, and counting it in a "has website" filter inflates the number. Store the kind and let the template label it honestly.
Extend the social list for your niche. Restaurants often list ordering platforms and salons list booking platforms. Decide per directory whether those count as a website.
Use the clean values for matching
Once phone numbers and hosts are normalized, they become useful matching keys. Two rows with the same E.164 number and the same host are very likely the same business, even if the names differ slightly. That makes a good second check alongside the place ID, which remains the most reliable key when both exports include it. For the full matching side, see this guide on how to find and remove duplicates in a Google Maps export.
Be careful with shared numbers. Franchise call centers, salon suite buildings and medical groups often list one phone for many locations. Treat a phone match as a hint, not a verdict, when the addresses differ.
Log what changed
Write a small report after each run: how many phones failed to parse, how many URLs turned out to be social profiles, how many rows changed since the previous export. A sudden jump in failures usually means the export format changed, not that half the businesses in town changed their numbers overnight. Catching that before a rebuild saves you from shipping a site full of empty phone fields.
For more on scraping, cleaning and refreshing listing data, the notes on Google Maps listing data cover the rest of the pipeline. 1 Click Directory Builder turns a Google Maps export into a complete static directory, and clean phone and website columns help its listing cards and contact actions work the way visitors expect.
Questions about normalizing export data
Why store phone numbers in E.164?
It's one unambiguous format that includes the country code, so comparisons work across exports and tel: links behave the same on every device.
Should I drop listings with invalid phone numbers?
Usually not. Keep the listing, hide the phone and fall back to the website or a contact form. Check a few by hand in case the parser got it wrong.
Is a Facebook page a website?
For filters and labels, treat it as a social profile. Show the link, but don't call it a website.

