Sub topic 8
Leading zeros, dates and other type pitfalls
Assume you can use the File > Import dialog, recognize CSV columns and rows, and write basic formulas such as TEXT and TRIM. This chapter focuses on what happens after Sheets reads the file. During import, Sheets often infers a data type from the text. A value may become a number, date, Boolean value, or formula instead of remaining unchanged text.
Why imported values change
A CSV file stores characters separated by delimiters. It does not normally store column types. For example, 00127 and 127 may both be interpreted as the number 127. A value such as 03/04/2026 may become a date, but its meaning depends on the spreadsheet locale.
The import process can therefore change how a value is displayed and how formulas compare it:
flowchart TD
A[CSV text] --> B[Import parser]
B --> C{Type inferred}
C --> D[Number]
C --> E[Date or time]
C --> F[Text]
C --> G[Formula]
D --> H[Check and clean]
E --> H
F --> H
G --> HLeading zeros
Leading zeros matter for identifiers, not quantities. Postal codes, employee IDs, product codes and account numbers often need to stay as text.
| Source value | Possible imported value | Risk |
|---|---|---|
| `00127` | `127` | The identifier no longer matches another system |
| `00045` | `45` | A fixed-width code loses its required length |
| `00012.50` | `12.5` | Formatting and exact text are lost |
If the imported value is in A2 and always has five digits, restore its display with:
=TEXT(A2, "00000")This creates text with five positions. It does not recover zeros if the source had a variable length and you do not know the intended width. For reliable imports, format an identifier column as Plain text before importing when the import method allows it. Alternatively, add a marker in the source, such as ID-00127, so the parser cannot treat it as a number.
Dates and times
Dates are stored internally as serial numbers, then displayed according to the spreadsheet locale and cell format. A CSV value such as 04/05/2026 can mean April 5 or May 4. An ISO value such as 2026-05-04 is less ambiguous, but it can still be parsed differently when combined with time zones or custom formats.
Check these points:
- Confirm File > Settings > Locale before importing.
- Prefer
YYYY-MM-DDin files shared across regions. - Inspect both the displayed value and the formula bar.
- Do not compare a date-looking text value with a true date until you know their types.
- Include a time zone when timestamps cross systems, for example
2026-05-04T14:30:00Z.
If a date was imported as text, DATEVALUE may convert it, but only when Sheets understands the text under the current locale. Test a small sample before filling the entire column.
Other type pitfalls
Import conversion can affect more than zeros and dates.
- Decimal and thousands separators vary by locale.
1,234may mean one thousand two hundred thirty-four or 1.234. - Values such as
TRUEandFALSEmay become Boolean values. - Text beginning with
=may be interpreted as a formula. Treat untrusted files carefully and inspect formula cells. - Empty strings, spaces and missing fields are different. A field containing spaces may look blank but fail a comparison.
- Very long numbers can lose precision when treated as numeric values. Keep tracking numbers and large identifiers as text.
- A UTF-8 file with the wrong encoding selection can display characters such as
éas garbled text.
Verify and clean the result
Check representative rows before trusting the whole import. Compare an identifier with its expected length, inspect an ambiguous date, and test a blank-looking cell.
For a text column in A2:A, remove surrounding and repeated extra spaces with:
=ARRAYFORMULA(TRIM(A2:A))Use LEN, ISNUMBER, ISTEXT and ISDATE-style checks such as ISNUMBER for dates, because Sheets stores true dates as numbers. For example:
=ISTEXT(A2)
=ISNUMBER(A2)
=LEN(A2)A clean import usually keeps raw data unchanged and places corrections in a separate sheet or helper columns. This preserves the original values for auditing.
A repeatable diagnosis
When a value looks wrong:
- Find the original text in the source file.
- Check the spreadsheet locale and import settings.
- Test whether the cell is text or numeric.
- Compare the formula-bar value with the displayed value.
- Apply a deliberate conversion, such as
TEXT,DATEVALUEorTRIM. - Spot-check the first, middle and last rows before using the data.
Exercise
A CSV contains the code 0042, but Sheets shows 42. What is the safest fix if the code must always contain four digits?
Show answer
Keep the column as plain text during import, or use =TEXT(A2, "0000") in a separate cleaned column. Do not rely only on a visual number format.