← Practical guides

When CSV 00123 appears as 123: find the conversion step

CSV has no column data-type declaration. A file can contain 00123 while a spreadsheet interprets it as the number 123. Follow three identifiers through the source file, this tool and Excel to locate the step where their interpretation changes.

Example files

Original CSV

UTF-8 BOM / comma / CRLF. A header and three data rows, with one space before and after Ana.

Download / 47 B

Downloaded tool copy

The actual output after trimming the surrounding spaces in one name cell.

Download / 45 B

Follow the steps

  1. Check identifiers in the source text

    Open the original in a text editor and find 00123, 00124 and 00007. Ana has one space on each side in the input below. Keep this original so you can compare it with another program’s interpretation.

  2. Inspect values and trim only the name

    Select the original in the CSV tool, choose comma as the delimiter and mark the first row as a header. Analyze it and inspect the original identifiers. Enable only surrounding-space removal. Leave blank-row removal and formula protection off, then download the modified copy.

    Open tool →
  3. Compare the downloaded source text

    The copy retains all three id values; the names are Ana, Min and Sol. One cell changed. Formula protection does not declare identifier columns as text, so enabling it is not required to preserve these leading zeros.

  4. Set the id column to Text during Excel import

    Use Excel’s text/CSV data import and set id to Text before loading it. If an automatic numeric conversion has already occurred, return to the original import and apply Text before conversion. See the Microsoft source below for version-specific menus and automatic-conversion options.

Measured results

The CSV tool retained all three identifiers as strings. In the installed Excel instance, importing column A explicitly as General produced the numbers 123, 124 and 7. Importing it explicitly as Text retained the three original strings.

id,name
00123, Ana 
00124,Min
00007,Sol
CSV sourceCSV tool copyExcel General importExcel Text import
001230012312300123
001240012412400124
0000700007700007

Download Excel observations (JSON)

Understand the result

Separate file content from a program’s display

If the text editor and this tool still show 00123 but Excel shows 123, the CSV has not lost those zeros. Check Excel’s type inference. If the source itself already contains only 123, this tool cannot determine its original length.

CSV quotes do not declare a text column

Quotes in CSV allow cells to contain delimiters and line breaks. Quoting a numeric-looking value does not prevent type inference in every spreadsheet. Specify the column’s meaning during import.

Displayed zeros and stored identifiers can differ

Formatting the number 123 as 00000 in Excel can display 00123 while the underlying value remains numeric. Importing an identifier as Text makes its meaning explicit for later use. Do not invent missing zeros or the original digits of a long number without the original source or a reliable rule.

When the result is different

The zeros disappear again when I reopen the exported CSV.
CSV does not store column types. Another opening can trigger numeric inference again. Import the column as Text and compare raw file values separately from displayed spreadsheet values.
My Excel already preserves the zeros.
Behavior depends on Excel version and automatic data-conversion settings. The General comparison deliberately reproduces numeric conversion; it is not a claim about the default settings of every Excel installation.
Can I turn an already saved 123 back into 00123?
You need the original or an external rule such as “all identifiers have five characters.” The value 123 alone cannot tell you whether the original was 123, 0123 or 00123.

Test conditions and sources

The browser check used the actual CSV analysis and downloaded output. Excel observations came from a dedicated hidden instance using OpenText with column A explicitly set to General or Text, reading actual cell values and types. User preferences were not changed. Results apply to the version and build shown below. Microsoft’s official instructions provide the corresponding screen-based import guidance.

Chromium 156.0.8078.4 / Windows /

Microsoft Excel 16.0 / Build 19127 / Windows (64-bit) NT 10.00

Microsoft: keeping leading zeros and large numbers

Download measurements and file checksums (JSON)