Practical workflow

Import CSV into Excel without losing leading zeros, codes, or accents

Import four sample rows as text, check exact values, and spot unwanted conversions. Includes a CSV sample and an optional local checker.

Chill&AutomateUpdated October 17, 20266 min read

Import a synthetic CSV as text and verify every identifier and accented name against the original.

Opening a CSV can turn the code 00123 into 123. Another code may start looking like a date. In a customer or item list, this is more than a display issue: you need to preserve the original identifier. Making the cell look right again with formatting is not enough.

Use four fictional rows to set up a controlled import and compare the result with exact expected values. These instructions cover Excel for Windows on desktop, using From Text/CSV and the Power Query Editor. Menu names can vary by version and language. This guide does not promise the same controls on Mac or the web.

Prepare the original and the expected result

Download the sample CSV and keep it unchanged. It uses UTF-8 encoding and a comma delimiter. Open it in a text editor first, rather than double-clicking it in Excel. Its contents should be exactly:

row_key,identifier,name
R1,00123,Žofie
R2,03-04,Řehoř
R3,1E10,Šárka
R4,00007,Jiří

All names and codes are synthetic. Here, 03-04 is not a date and 1E10 is not a number for calculation: both are text identifiers. The styling in the table below only distinguishes exact text values; do not add any extra characters to the cells.

row_key identifier, exact text name, exact text
R1 00123 Žofie
R2 03-04 Řehoř
R3 1E10 Šárka
R4 00007 Jiří

An expected matrix in JSON is also available. It is the reference specification for this example, not an import result. For your own export, you need your own preserved original and expected values.

Import with explicit data types

When you open a CSV directly, Excel interprets columns using its default settings. Microsoft describes a separate text/CSV import procedure for controlling the import. See the CSV import documentation, checked October 17, 2026.

  1. In a new workbook, choose Data → From Text/CSV and select the original sample file.
  2. In the preview, set UTF-8 and the comma delimiter. You must see three separate columns and correctly accented names. If all the data appears in one column, fix the delimiter first.
  3. Choose Transform Data. Do not load the result into the worksheet yet.
  4. In the Power Query Editor, inspect Applied Steps. If there is an automatically added Changed Type step, remove that automatic conversion. For this example, then set all three columns — row_key, identifier, and name — to the Text data type. If the editor offers to replace an existing conversion, replace it; do not add another conversion to text after a damaging conversion.
  5. Check that the preview after setting the types contains the original values, especially 00123, 03-04, 1E10, and 00007. If any value already differs, return to the intact CSV and repeat the import.
  6. Use Close & Load. In the loaded worksheet, check all four rows against the table above again, including the names. Select each cell and inspect its contents in the formula bar too; the cells’ appearance alone is not sufficient evidence of a match.

Microsoft describes importing with the Text type and the limits of later formatting in its guide to leading zeros and large numbers, checked October 17, 2026. Formatting alone cannot restore zeros that have already been removed. Do not guess how many zeros to add to your own data: a shortened value does not tell you whether the original code had five, six, or some other number of characters.

Respond to the specific mismatch

What you find What to do
One column instead of three Return to the import and select the comma delimiter.
Broken accents already in the preview Check UTF-8 and compare the text original. If the original is already wrong, request a correct export.
Missing zeros or a changed code Inspect the type-conversion steps and import the original file again as text.
A cell looks right only because of formatting Compare its actual contents; do not hide incorrect values behind a display format.
A missing or duplicate row_key Stop checking the result and establish where a row was lost or added.

Save the finished workbook as XLSX so that subsequent work continues with the workbook’s columns and types. If you export a CSV later, check that new file again. Opening a CSV directly another time does not guarantee that types will be preserved.

Optionally compare an export with a local script

Checking the four rows manually is enough to complete this example. To check values after exporting from Excel as well, download the Python 3 checker. It needs no additional packages. It is designed solely for the synthetic specification above; do not feed your own customer files into it as though it were a general-purpose validator.

You can check the starting file first. In a terminal in the folder containing the downloaded files, run:

python3 check-csv-import.py csv-import-sample.csv

Then export a copy of the sample worksheet from Excel as CSV UTF-8, for example csv-import-result.csv. Do not overwrite the original. Run the same command with the new filename:

python3 check-csv-import.py csv-import-result.csv

For an exact match, the script prints:

OK: 4 rows; all values match the sample exactly.

If 00123 becomes 123, for example, it reports the specific difference:

R1 / identifier: expected '00123', found '123'.

The script requires the exact header, three fields per row, and precisely the keys R1 through R4 without duplicates. Data rows can be in a different order: it matches them by row_key. It compares values character by character, including spaces and accents. It does not repair, pad, or send anything over the network; it does not use AI. It accepts UTF-8 with an optional leading BOM and a comma delimiter. If your export uses semicolons or a different header, it rejects it; that alone does not prove an identifier was damaged.

Exit code 0 means a match, 1 means a mismatch or invalid CSV structure, and 2 means a usage or file-reading error. Invalid UTF-8 decoding is a reading error. Python reads CSV fields as strings by default; see the csv module documentation, checked October 17, 2026.

A successful check establishes that the values in the checked CSV match this example. It does not establish XLSX cell types, the correctness of another export, or the completeness of a business report. Check types during import and values in the loaded worksheet as well.

Carry the checks into your next import

Preserve the source first, identify text codes, and only then load the data. Treat a match between actual values and the original as completion, rather than an attractive cell display. If reports or automations will consume the spreadsheet, pass on only the verified result and keep the source for recovery.

This procedure is based on vendor documentation and a synthetic specification. It is not a report of an import performed in an authenticated Excel account or of a customer result. Data verification remains a separate step each time you use it.

Templates and resources

Check your result

Do I have enough evidence for the next step?

Checks are temporary reminders on this page. They are not saved and do not verify the outcome for you. Record evidence in your own notes or the downloadable worksheet.