Sub topic 13
Build a Repeatable Data-Cleanup Pipeline
Assume you know how to select ranges, use the menu bar, and enter simple formulas. This chapter uses a raw sheet named Raw and a separate sheet named Clean. Keeping these sheets separate lets you rerun the cleanup when new data arrives.
A cleanup pipeline is an ordered set of transformations. Each step takes the result of the previous step. A useful order is:
- Preserve the raw values.
- Remove hidden and extra spaces.
- Standardize capitalization.
- Split combined values.
- Flag or remove duplicates.
- Check the result.
Start with a copy of the raw data
Do not clean the only copy of your imported data. Duplicate the sheet or copy the values into a Raw tab. Use the raw tab for comparison and the Clean tab for formulas.
Suppose Raw!A2:A contains names, Raw!B2:B contains email addresses, and Raw!C2:C contains phone numbers. A name may contain extra spaces, an email may contain invisible characters, and a phone number may contain punctuation.
Clean spaces, hidden characters, and capitalization
In Clean!A2, normalize names with one formula:
=ARRAYFORMULA(PROPER(TRIM(CLEAN(SUBSTITUTE(Raw!A2:A, CHAR(160), " ")))))SUBSTITUTE changes non-breaking spaces into ordinary spaces. CLEAN removes many non-printing characters. TRIM removes leading and trailing spaces and reduces repeated spaces. PROPER changes text such as jANE doe to Jane Doe.
For email addresses, use lowercase rather than proper case:
=ARRAYFORMULA(LOWER(TRIM(CLEAN(SUBSTITUTE(Raw!B2:B, CHAR(160), " ")))))Do not apply PROPER to email addresses. Email text can contain characters whose case should remain unchanged for reliable comparison, even though most email systems treat addresses as case-insensitive.
For phone numbers, remove formatting characters:
=ARRAYFORMULA(REGEXREPLACE(Raw!C2:C, "[^0-9]", ""))REGEXREPLACE uses a pattern. [^0-9] means “any character that is not a digit.”
Split combined values before deduplication
If Raw!D2:D contains entries such as Doe, Jane, split them into separate columns on the Clean sheet:
=ARRAYFORMULA(SPLIT(TRIM(Raw!D2:D), ",", FALSE))The FALSE argument tells SPLIT to treat the delimiter as the complete string. This matters when the separator is more than one character, such as ", ".
If the source contains names in Last, First format, splitting creates separate fields, but it does not decide which field belongs in a final First name or Last name column. Label those columns clearly and verify several rows.
Deduplicate the cleaned table
After the cleanup formulas produce a complete table, create a deduplicated view in another area:
=UNIQUE(A2:D)UNIQUE returns distinct rows without changing the source table. It considers the entire row, so two rows with the same name but different email addresses are not duplicates.
For a reviewable workflow, flag repeats before removing them. In a helper column beside the cleaned table, enter:
=COUNTIF($B$2:B2, B2) > 1Fill it down. TRUE marks every repeated email after its first appearance. Review those rows for legitimate cases, then use Data cleanup > Remove duplicates only when you are certain that the selected columns define a duplicate.
Verify the result
Compare the cleaned table with Raw. Check that:
- Names have consistent spacing and capitalization.
- Emails contain no leading or trailing spaces.
- Phone values retain all expected digits.
- Splitting did not shift values into the wrong columns.
- Duplicate flags were reviewed before deletion.
- The number of meaningful rows is plausible.
A repeatable pipeline is safer than manually editing cells because you can replace the raw data and recalculate the same transformations.
Exercise
Your cleaned email column contains [email protected] and [email protected]. Which formula should you use first, and what should you check before treating them as duplicates?
Show answer
Use =ARRAYFORMULA(LOWER(TRIM(CLEAN(SUBSTITUTE(Raw!B2:B, CHAR(160), " "))))). Check that the two rows represent the same record and that email is the correct field for defining duplicates.