Mapping Google Maps Export Columns to a Directory Data Model
If you have been asked to build a local directory from a Google Maps export, the first file you open can be a little overwhelming. Dozens of columns, some nested data stuffed into a single cell, and field names that chan
If you have been asked to build a local directory from a Google Maps export, the first file you open can be a little overwhelming. Dozens of columns, some nested data stuffed into a single cell, and field names that change depending on which tool produced the file. Before writing any templates, it pays to decide what your own data model looks like and map the export into it.
This post is a beginner's walk through that mapping step. It does not assume a particular framework or scraper. The same thinking applies whether the CSV or JSON came from Outscraper, Apify or any scraper, and whether you render pages with a static site generator or a hand-written script.
Why you want your own model
It is tempting to feed the raw export straight into your templates. That works for a demo and breaks the first time you refresh the data. Column names may differ between tools, between export settings or between versions of the same tool. If your templates read raw column names, every change ripples through the whole site.
A small internal model fixes that. You write one mapping function per data source, and everything downstream reads your fields. When the export changes, you update the mapping and nothing else.
The fields most directories need
You do not need every column. Start with what a listing page and a city page actually display, plus what you need to match records over time.
{
"id": "place id from the export",
"name": "Riverside Bakery",
"category": "Bakery",
"categories": ["Bakery", "Cafe"],
"phone": "+15555550123",
"website": "https://example.com",
"address": { "street": "", "city": "", "region": "", "postal": "" },
"location": { "lat": 0, "lng": 0 },
"hours": { "mon": [["08:00", "17:00"]] },
"rating": 4.6,
"reviewCount": 212,
"status": "operational",
"updatedAt": "2026-11-30"
}
That is enough for county, city and category pages, a map, filters and a detail page. Anything else, such as photos or attributes, can be added once the basics are solid.
The identifier comes first
The most important field is the one visitors never see. Google gives each place an identifier, and most exports include it in some form. Use it as your primary key. Names change, phone numbers change and addresses get reformatted, but the place identifier is the best handle you have for knowing that two rows in two exports are the same business. There is a longer explanation of using Google Place IDs to match listings across exports if you want the details on edge cases.
If a row has no identifier, generate a fallback from a normalized name plus postal code, and flag it so you can check it by hand.
Fields that need cleaning on the way in
A few fields almost always need work during the mapping step.
- Phone numbers come in mixed formats. Store one normalized format and format for display in the template.
- Websites may include tracking parameters or point to a social profile. Strip the tracking and decide whether social links count as a website.
- Categories arrive as a main category plus a list. Keep both, but map the main one to your own category list so your pages are not at the mercy of whatever label a business picked.
- Hours are often a single text string per day. Parse them into open and close times, and keep the original string so you can debug parsing mistakes.
- Addresses may be one long string or several parts. Split them consistently, because the city part drives which city page a listing appears on.
Do the cleaning inside the mapping function so the rest of the code can trust what it receives.
Validate before you build
After mapping, run a quick validation pass. It does not need a library. Loop through the records and count:
- Records missing an id, name or city.
- Records whose city does not match any city page you plan to build.
- Records with coordinates outside your target area.
- Duplicate ids.
Print the counts and a few examples of each. A build that fails loudly on bad data is far better than a site that quietly puts a Phoenix bakery on your Portland page.
Keep the raw file
Always keep the original export alongside your mapped data, named with the date. When something looks wrong on the live site, you will want to trace it back to the exact source row. It also lets you rerun the mapping after you fix a bug without exporting again.
If you are new to directory projects in general, the beginner guides to building a local directory cover the planning side that comes before any code.
If you would rather skip writing the mapping and templates yourself, 1 Click Directory Builder takes a Google Maps export and turns it into a complete static directory site, with county and city pages, search, filters, a map and a sitemap.
Questions about mapping export data
Should I use CSV or JSON exports?
Either works. JSON keeps nested fields like hours and categories intact, which saves parsing. CSV is easier to open and check in a spreadsheet. Many developers export both and map from JSON.
Where should the mapping code live?
Keep it in its own module, one function per source. That way adding a second scraper later means adding one function, not touching templates.
How do I handle businesses with several categories?
Store the full list, but pick one main category for page placement. Let filters use the full list so the business can still be found under its other categories.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.