Skip to content

How it's builtAutomation

Data Cleaner

A clean-up workflow for a customer sheet merged from three sources. It profiles each column, fixes what is safe to fix, flags what needs a person, merges duplicates, and hands back a clean CSV with a change log, all in your browser.

The problem

Every business that moves to a new CRM, or merges a web form, a sales spreadsheet and an old export, meets the same mess: one customer three times, phone numbers in six shapes, dates nobody can be sure of, cities under their old names. Imported as it is, it fills the new system with duplicates and bounced messages.

Cleaning by hand takes days and leaves no record of what changed. A workflow does the safe fixes in seconds, shows every change, and leaves only the real judgement calls to a person.

The data

Kovai Events is fictional, and so is its sheet: 300 rows from a web form, a sales spreadsheet and an old CRM export, generated from a fixed seed. The names, emails, phone numbers, PIN codes and GSTINs are made up; the GSTINs are built with the real check-character rule, so most of them pass it.

Each source adds the mess it would in real life: lower case and capitals, "R. Karthik" and "KARTHIK R", "gmial.com" and "yahoo.co", "+91-98400…", "098400…" and Coimbatore landlines, dates as "14-Mar-2025", "03/04/2025" or Excel day numbers, "CBE", "Kovai" and "Madras", PIN codes a digit short, GSTINs with a wrong check character, and budgets written "₹1,20,000", "1.2 L" or "1.5 Cr".

35 of the rows are customers entered a second or third time, with small differences, and 8 pairs of different customers have look-alike names, so the duplicate finder has something to get wrong. Because I generated the sheet, I know which rows are the same person, which is how the results below are checked.

The model

Profile. A column's type comes from its header first and its values second, so a file with its own headings still gets the right rules. The profile runs every rule as a dry run, so the counts on each card are exactly what the clean-up then does.

Fix. One set of rules per type. Names are trimmed and cased, and "Surname, Name" is turned round. Emails are lower-cased. A common provider's name typed with two letters swapped, or with a double letter typed once or a letter typed twice ("gmial.com", "yaho.co.in"), is corrected, but only when the rest of the domain is exactly the provider's. I never change the ending, so a real address at yahoo.co.jp or hotmail.co.uk stays as it is, and a near miss such as "gmail.co" or "gmal.com" is flagged with a suggestion instead. Phones become +91 numbers, with landlines labelled by their STD code. Dates become ISO. Cities go through a table of old names and short forms, then a spelling check. Amounts lose their symbols, their lakh and their crore. A rule changes a value only when the change is safe; otherwise the value stays and the cell is flagged. 03/04/2025 could be 3 April or 4 March, so I flag it, with the column's own habit as a hint, instead of guessing. A row with more cells than the header keeps the extra ones in new columns, flagged with the row they came from.

GSTINs are checked with the standard check character, a Luhn mod 36 sum over the first 14 characters, and the state code is checked against the customer's city.

Duplicates. Rows that are the same in every column once cleaned are merged first, in one pass, however many copies there are. Comparing every other pair gets slow on a big sheet, so rows are blocked on phone, email and the start of each word of the name, and only rows sharing a block are compared. In a block of more than 80 rows, such as a very common name, only rows with the same phone or email are compared, and the demo says how many rows that touched. Each pair scores 0.7 × name similarity (Jaro-Winkler word by word, where an initial matches any word starting with that letter, so "Sowmya K" meets "Sowmya Krishnan"), plus points for the same phone, email or company, minus points for conflicting ones. Pairs over the threshold join into groups, and each group gets a proposed record: the fullest name, the latest date, the highest budget, and otherwise the most common value that passed its checks. You accept or reject each one.

The pipeline

  1. 01
    Load

    Comma, semicolon or tab, guessed from the first line. Cells beyond the header go into extra columns, never dropped.

  2. 02
    Profile

    Type, gaps and distinct values per column, and a dry run of every rule.

  3. 03
    Fix

    Safe fixes column by column; doubtful cells flagged with a reason and, where possible, a suggestion.

  4. 04
    Find duplicates

    Exact copies first, then block, score with Jaro-Winkler and exact matches, and group above the threshold.

  5. 05
    Validate

    PIN code against city, GSTIN state against city, and a working phone or email.

  6. 06
    Export

    A clean CSV with phone types and review notes, and a change log with every edit.

Results

Cells fixed
1,114
37.1% of the 3,000 cells
Left for a person
76
items in 66 rows
Duplicate pairs found
38 of 40
none wrong, at 0.85
Pairs compared
4.6%
2,085 of 44,850, after blocking

Measured when this page was built, on the sample, with the same code the demo runs. Loosening the threshold to 0.65 finds every planted pair but also groups 9 pairs of different people, which is why each group waits for a yes.

For a client

For a real migration I would agree the rules with the team first (which source wins for a phone number, which date formats each source used), run them on the full export, and hand over the "needs a person" list as a sheet the team can work through.

The same workflow can run on a schedule against the CRM, so new entries are cleaned as they arrive instead of once a year. Where rules are not enough, such as company names written many ways, I would add a small model trained on the team's own merge decisions.

None of it needs a server. For very large files the same code runs in a background worker, or as a small job next to the database.

Stack

PartWhat it does hereLicence
My cleaning rules and duplicate finderProfiling, the fixers, the GSTIN check, blocking, scoring and merging, in TypeScript and unit-testedMine
My machine-learning libraryJaro-Winkler and Levenshtein distances, and the text key for matchingMine
PreactThe workflow, the tables and the duplicate reviewMIT
AstroThe page, built as static HTMLMIT

Privacy

Your file is read in your browser and never uploaded: there is no server behind this page. The clean file and the change log are made on your device.

Limits

  • The rules know Indian phone numbers, PIN codes, GSTINs and a list of South Indian cities; other countries and places need their own.
  • When two rows disagree (two budgets, two phone numbers) the merge picks by simple rules. The group's card shows the choice, but it cannot know which one is true.
  • Name matching works on spelling, not meaning: "Bala" and "Balasubramanian" may be one person, and it will not know.
  • On a big sheet, a block of more than 80 rows (a very common name) is compared only where the phone or email is the same, so a duplicate there with a new phone and a new email can be missed.
  • Ambiguous dates stay as they are until a person decides.