How to Clean a CSV Before Importing to Google Sheets — Free
Table of Contents
Google Sheets handles CSV imports better than most tools, but it is not immune to formatting problems. A trailing space in a key column breaks VLOOKUP. Empty rows throw off row count formulas. Mixed-case emails prevent MATCH from finding records. And Sheets has its own auto-formatting behavior that can silently change values once the CSV is loaded.
The free CSV Data Sanitizer handles the formatting cleanup before the import — so you are working with clean data from the moment the file opens in Sheets. Browser-based, no upload, works on Mac, Windows, and Chromebook.
How Google Sheets Handles CSV Imports
When you import a CSV into Google Sheets (File > Import), Sheets gives you options for separator type and whether to convert text to numbers/dates. The defaults are usually sensible but there are behaviors worth knowing:
- Auto-number conversion — Sheets automatically converts values that look like numbers. "01234" becomes 1234, dropping the leading zero. Phone numbers stored as plain digits may get converted. ZIP codes lose leading zeros.
- Auto-date conversion — values that look like dates ("01/15/2024") get converted to Sheets date format. Whether this is useful depends on what you are doing with the data.
- Whitespace preservation — Sheets imports whitespace exactly as it appears in the CSV. "[email protected] " (with trailing space) stays "[email protected] " in the cell. This looks correct visually but breaks formulas.
- Empty rows are imported — Sheets does not skip empty rows. A blank row in your CSV becomes a blank row in the sheet, which disrupts COUNT, COUNTA, and range-based formulas.
Most of these are not Sheets problems — they are problems with the source CSV that become visible once loaded into Sheets.
Whitespace in Google Sheets — Why It Breaks Formulas
Trailing spaces are the most common issue for anyone who uses VLOOKUP, MATCH, or QUERY in Sheets to work with imported CSV data.
Example: your CSV has customer email addresses. You import it into Sheets. You use VLOOKUP to find purchase history by email. Half the lookups return #N/A even though you can see the email in both columns. The problem: one column has "[email protected]" and the other has "[email protected] " (trailing space). To VLOOKUP, those are different strings.
The same issue applies to:
- MATCH and INDEX-MATCH — exact match mode (0) treats trailing spaces as part of the value
- COUNTIF and SUMIF — criteria matching is space-sensitive; the count is lower than expected
- QUERY function — WHERE clauses comparing string values fail when one has trailing spaces
- Pivot tables — "Acme Corp" and "Acme Corp " appear as two separate entries
You can fix this in Sheets after import using TRIM() in a helper column, but that adds overhead. Fixing before import means your data is correct from row 1.
Sell Custom Apparel — We Handle Printing & Free ShippingHow to Clean the CSV Before Importing to Google Sheets
- Open the CSV Data Sanitizer
- Upload your CSV or paste the text directly — the file never leaves your browser
- Enable the fixes relevant to your data:
- Trim whitespace — always enable this for any CSV going into Sheets. Prevents the VLOOKUP/MATCH failures described above.
- Remove empty rows — enable if your CSV has blank lines. Keeps row count formulas accurate.
- Lowercase emails — enable if you will be doing email-based lookups or deduplication in Sheets
- Remove duplicates — enable if you merged multiple exports before importing
- Click Clean CSV and review the stats
- Download the cleaned CSV
- Import to Google Sheets: File > Import > Upload > your cleaned file
When Sheets asks about separator type, select "Comma" for standard CSV files. For the "Convert text to numbers and dates" option, consider whether you want Sheets interpreting your data — if you have ZIP codes or other numeric strings that should stay as text, leave this unchecked.
Protecting ZIP Codes and Phone Numbers During Import
Google Sheets auto-formatting can change data you did not intend to change:
- ZIP codes — "07030" becomes 7030. The leading zero is gone permanently once Sheets converts it to a number.
- Phone numbers — "15551234567" (11 digits) may be displayed in scientific notation
- IDs with leading zeros — any numeric-looking value with a leading zero loses it
Two ways to prevent this:
Option 1 — Uncheck number conversion on import. When importing, uncheck "Convert text to numbers, dates, and formulas." All values import as text. You can format individual columns as numbers later if needed.
Option 2 — Quote the values in the CSV. Values wrapped in quotes that also contain a leading apostrophe force Sheets to treat them as text. This requires editing the CSV before import, which adds complexity.
The CSV Sanitizer formats US phone numbers to (xxx) xxx-xxxx — this format includes parentheses and hyphens, which prevents Sheets from treating it as a number. For ZIP codes, the sanitizer does not modify numeric columns, so you will need to handle leading zeros with the import option.
After Import — Quick Formula Checks to Confirm Clean Data
After importing your cleaned CSV, run these quick checks before building anything on top of the data:
- LEN() spot check — in a blank column, enter
=LEN(A2)for a key column (like email). If you see numbers higher than expected for some cells, there may still be hidden whitespace. - COUNTA vs. row count —
=COUNTA(A:A)-1gives you data rows (minus header). Compare to the file row count. A difference means empty rows or missing values. - COUNTUNIQUE for deduplication check —
=COUNTUNIQUE(A2:A1000)on your key column (email, ID) tells you how many unique values exist vs. total rows. If those numbers differ significantly, there are duplicates.
If the checks pass, the data is clean and your formulas and lookups will work correctly from the start.
For more complex column operations once the data is in Sheets, see the Column Operations tool — it handles math, concatenation, and text transformations on CSV columns without needing Sheets formulas.
Try It Free — No Signup Required
Runs 100% in your browser. No data is collected, stored, or sent anywhere.
Open Free CSV SanitizerFrequently Asked Questions
Does Google Sheets handle large CSV files well?
Google Sheets has a 10 million cell limit. A CSV with 100 columns and 100,000 rows hits that limit exactly. For larger files, consider importing in chunks or using Google BigQuery for data analysis instead of Sheets.
Can I import directly from a URL instead of uploading a file?
Yes. Google Sheets has an IMPORTDATA function that pulls CSV data from a public URL and refreshes periodically. This is useful for live data feeds but not for one-time imports of exported CSVs. For exported files, the File > Import method is the right approach.
My CSV has special characters that appear garbled after import. Is this a whitespace issue?
No, garbled special characters are an encoding issue, not a whitespace issue. The most common cause is a CSV saved in Latin-1 or Windows-1252 encoding being imported into Sheets (which expects UTF-8). Re-export the CSV from the source system with UTF-8 encoding selected, or use a text editor to convert the encoding before importing.

