Desk Clarity

Everyday document & browser help

CSV Leading Zeros Missing? Check Export and Opening Separately

By ON Lab · Sources checked November 6, 2026

If a code such as 00123 becomes 123 after moving a CSV between Google Sheets and another program, find the stage where it changes. Inspect a copy of the CSV as text before reopening it in a spreadsheet. If the zeros are still in the file, changing the export again addresses the wrong stage: the receiving program may be interpreting the field as a number.

Decide whether the value is a number or an identifier

A quantity used in arithmetic is different from an identifier whose exact characters matter. Postal codes, product codes and account references can look numeric while needing text treatment. Before applying a five-zero pattern, establish the real rule for that column.

This matters because 123 might represent an intended 00123, but it could also be a valid three-character identifier. A formatting formula cannot discover which original string was lost. Do not pad every field to five characters unless the data specification requires exactly five.

Preserve the original and trace one harmless example

  1. Keep the source workbook and the exported CSV unchanged. Work on copies.
  2. Choose a row whose exact expected code you know. If the data is private, use a synthetic example in a separate test sheet.
  3. Record the code visible in the source sheet and whether it is meant to be text or a numeric display.
  4. Export the intended sheet to CSV using the application's supported download/export control.
  5. Open a copy of that CSV in a trusted local text editor. Find the same row and read the characters in the field.
  6. Compare that raw field with what the destination spreadsheet displays after opening or importing it.

Do not upload private customer or account data to an online CSV checker. The inspection needs a few known fields, not a public copy of your whole dataset. The following invented row illustrates the acceptance criterion:

record_id,postal_code
sample-a,00123

If the text file still contains 00123 but the spreadsheet shows 123, the source-to-CSV step preserved the characters for that row. That is a narrower and more useful result than “CSV always removes zeros.” It does not yet prove every other row or column is intact.

If the exported file already lacks the zeros

Return to the source data before exporting again. Check whether the original identifier was retained as text or whether a number was merely displayed with a custom format. Google's formatting help distinguishes number-display patterns, and its TEXT function explicitly creates text according to a pattern.

For a column that is genuinely defined as five digits, Google's documented function syntax supports an example such as =TEXT(A2,"00000"). A value of 123 produces a five-character text result, 00123. Use a separate column so you can compare the original and result before replacing anything. Match your spreadsheet's accepted formula syntax if its locale differs.

This is reconstruction according to a known width, not recovery of an unknown original identifier. It should not be applied to mixed-width codes, alphanumeric identifiers or damaged long account numbers without the correct specification.

If the CSV is correct but Excel changes the display or value

Microsoft documents automatic conversion of numeric-looking text, including removing leading zeros and reducing numeric precision. Its supported import approach uses Data → From Text/CSV and the query editor to set the relevant column's data type to Text before loading it.

In Microsoft's instructions, open the import preview, enter the query editor, select the code column, and change its data type to Text. Replace the current type when prompted, then load the result. Labels can differ by Excel version; follow the linked official procedure for your installation rather than assuming that double-clicking the CSV gives the same controlled import.

After loading, compare the known test row again. Set the text type before relying on the converted column. Formatting a value after an earlier conversion may not restore information that was already removed.

Use display formatting only for the right purpose

Google Sheets supports custom number formats through Format → Number → Custom number format. Microsoft's Excel guide also describes zero-padded custom displays when the requirement is confined to a workbook. A visible five-digit display alone is not proof that another program will interpret a CSV field as the same text identifier.

In Excel, Microsoft documents a maximum precision of 15 significant digits for numeric values. For identifiers of 16 digits or more, use text before entry or import. Adding zeros afterward cannot reliably reconstruct digits that were rounded away. Return to the authoritative source when that has happened.

Complete an end-to-end acceptance check

Compare more than the first row: include a leading-zero example, a value at the expected width, an alphanumeric code if allowed, and a long identifier if the dataset contains one. Check the source, raw CSV and destination side by side. Record which stage first differs.

If the destination is an upload form or another application, inspect its own field-type requirements. Do not add spreadsheet formulas or an extra apostrophe to an interchange file simply to make a spreadsheet display look right; those characters may become part of the imported data.

When the comparison passes, save a separate verified output and retain the original until the receiving task is complete. If it fails, stop overwriting files and report the source format, export route, destination import method and one nonprivate example. That record tells the next person whether to investigate export, parsing or prior loss.

Scope: Google Sheets formatting/TEXT and Microsoft's documented Excel import and precision behavior, combined with editorial file-stage checks. Examples are synthetic. No private spreadsheet was opened, and no claim is made that an unknown original identifier can be recovered.

Sources