Sub topic 9
Checking and Cleaning Imported Data
Assume you know how to work with cells, sheets, and basic formulas. You should also know what CSV and Excel files are. This chapter uses an imported sheet named Imported, with column headers in row 1.
An import can finish without an error and still produce incorrect data. Google Sheets may change text into numbers, interpret dates using the spreadsheet locale, remove leading zeros, or include unwanted spaces. Check the result before using it in reports or formulas.
Verify the import
Start with a structural check:
- Confirm that the expected sheet exists.
- Check the number of columns and rows.
- Confirm that row 1 contains the expected headers.
- Compare a few records with the original file.
- Look for blank columns, shifted values, or broken rows.
- Check that formulas, dates, identifiers, and amounts have the expected types.
The following workflow catches common problems:
A quick way to inspect missing values is to turn on a filter. Select the header row and choose Data > Create a filter. Open a column's filter menu and inspect the empty values. Filters also help you find unexpected categories, such as both Paid and paid .
Use conditional formatting to highlight duplicates or suspicious values. For example, select an identifier column, choose Format > Conditional formatting, and use a custom formula such as:
=COUNTIF($A$2:$A,A2)>1This highlights identifiers that appear more than once. Confirm whether the duplicates are errors or valid repeated records before deleting anything.
Clean spaces and inconsistent text
Imported text often contains leading or trailing spaces. These spaces are difficult to see and can make lookups fail. In a new column, enter:
=ARRAYFORMULA(TRIM(A2:A))TRIM removes extra spaces from each nonempty value in column A. Keep the original column until you have checked the cleaned results. If the values are correct, copy the new column and use Edit > Paste special > Values only to replace the original values.
TRIM does not fix every whitespace character. Data copied from web pages may contain nonbreaking spaces. In that case, use:
=ARRAYFORMULA(TRIM(SUBSTITUTE(A2:A,CHAR(160)," ")))Check category columns for spelling and capitalization differences. A pivot table or the UNIQUE function can show the values that actually exist:
=UNIQUE(FILTER(B2:B,B2:B<>""))Restore identifiers and check types
A postal code, account number, or product code may look numeric but should be treated as text. If an import removed leading zeros from five-digit postal codes, create a corrected value with:
=TEXT(A2,"00000")This displays 123 as 00123. Do not use this repair unless every valid identifier should have exactly five digits. For variable-length codes, the original file or a documented rule is safer.
Dates deserve special attention. A value such as 03/04/2026 can mean March 4 or April 3 depending on the spreadsheet locale. Select the column and check Format > Number > Date. Compare ambiguous dates with the source file. If the imported values are text, changing the display format will not convert them. You may need to parse the text explicitly after confirming its order.
Numbers can also import as text because of currency symbols, thousands separators, or decimal conventions. Test a suspected numeric cell with:
=ISNUMBER(C2)A result of FALSE means formulas such as SUM may ignore the value. Remove unwanted characters only when you understand the source format. For example, a value using commas as thousands separators may need a controlled conversion rather than a global replacement.
Recheck the cleaned data
After cleanup, verify the results again:
- Compare row and column counts with the source.
- Recalculate important totals and compare them with the original.
- Test a lookup using a known identifier.
- Check that required fields are not blank.
- Review dates near month or year boundaries.
- Confirm that identifiers still have the required length.
- Remove temporary helper columns only after verification.
A clean-looking sheet is not proof that the import is correct. Preserve the source values and record any assumptions, such as the date order or identifier length.
Exercise
Column A contains imported postal codes. The value 00127 became 127. What formula restores the five-digit display, and what should you verify first?
Show answer
Use =TEXT(A2,"00000"). First verify that every valid postal code should contain exactly five digits and compare the result with the source file.