Comparing business listings field by field: normalise phone numbers and hours before you diff
If you check how a business appears on Google, Facebook and a couple of map apps, a naive string comparison reports almost everything as "different". +1 (555) 010-0199 and 555.010.0199 are the same phone. MonβFri 9β5 and
If you check how a business appears on Google, Facebook and a couple of map apps, a naive string comparison reports almost everything as "different". +1 (555) 010-0199 and 555.010.0199 are the same phone. MonβFri 9β5 and Monday-Friday 09:00-17:00 are the same hours. The real discrepancies drown in formatting noise.
The fix is to compare normalised values against one canonical record, never listing against listing.
1. Phone numbers: digits only, with a default country code
function normPhone(s, defaultCc = '1') {
let d = String(s).replace(/\D+/g, '');
if (d.length === 10) d = defaultCc + d; // national -> international
return d;
}
normPhone('+1 (555) 010-0199') === normPhone('555.010.0199'); // true
2. Opening hours: expand to a weekly minute grid
const DAYS = ['mon','tue','wed','thu','fri','sat','sun'];
// input: { mon: [['09:00','17:00']], ... } -> Set of "day:minute" slots in 15-min steps
function hoursSet(h) {
const out = new Set();
for (const d of DAYS) for (const [a, b] of h[d] || []) {
const toMin = (t) => { const [H, M] = t.split(':').map(Number); return H * 60 + M; };
for (let m = toMin(a); m < toMin(b); m += 15) out.add(`${d}:${m}`);
}
return out;
}
const sameHours = (x, y) => { const A = hoursSet(x), B = hoursSet(y);
return A.size === B.size && [...A].every((k) => B.has(k)); };
Parsing free text like "MonβFri 9β5" into that object is the messy part; once it is structured, equality is exact.
3. Unknown is not "same"
If you did not look at a field on a platform, store null and report it as not checked. Treating a missing value as a match hides exactly the errors you were looking for.
4. Report differences as rows
{ location, platform, field, listed, canonical, checkedOn, evidence } is enough to fix things and, later, to keep a dated change log. A before/after comparison of clicks or calls can then show what changed around a fix, but it cannot prove the fix caused it, and the report should say so.
We built these rules into Local Visibility & Business Profile Desk (paid, with a free demo), but the approach above works in any spreadsheet or script.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.