Productivity

How to Import a CSV into Excel Without Losing Leading Zeros

Keep postal codes and customer IDs intact when importing a CSV into Excel. Follow a small example, check the values, and avoid losing zeros on reopening.

The quick answer

In desktop Excel for Windows, use Data > From Text/CSV instead of opening the CSV directly. In the preview, choose Do not detect data types so identifiers stay as text, then check their full values before loading. Keep an untouched source copy. If zeros are already missing from the source file, importing as text cannot recover them.

In this guide

Postal codes and customer IDs are labels, even when they contain only digits. If Excel reads 00123 as a number, it becomes 123. The goal is to import the original characters as text. Microsoft explains this conversion.

This walkthrough targets Microsoft 365 or Excel 2024 on Windows. If your import controls differ, use the legacy wizard below. Mac, web, and mobile menus are outside this walkthrough.

1. Check an untouched source copy

Keep the original CSV and work with a copy. Open the copy in a plain-text editor such as Notepad, rather than double-clicking it into Excel. Look for a value you know should contain zeros.

  • If the file contains 00123, the characters are still available to import.
  • If it already contains 123, get a fresh export or confirm the correct code with its owner. Do not guess how many zeros belong there.

Opening a CSV normally uses Excel's default interpretation of each column. Microsoft's text-file import guide explains why an explicit import gives you more control.

Practice with three fictional records

Choose Save file to download sample-codes.txt, or copy this block into a plain-text file with that name. It contains comma-separated data; Excel can import the .txt file directly using the same Text/CSV connector. You do not need to rename it.

sample-codes.txt
customer_code,postal_code
00123,00501
00007,02108
04210,10001

The names and values are a practice dataset, not actual customer records. Keep both columns as text because neither column is an amount to calculate.

2. Import without automatic number detection

  1. Open Excel and create a blank workbook.
  2. Select Data > From Text/CSV in Get & Transform Data.
  3. Select your CSV, or sample-codes.txt, and choose Import.
  4. Set Delimiter to Comma for this sample. Confirm that the preview has two columns.
  5. Set Data type detection to Do not detect data types. This leaves columns as text. Check that the preview still contains 00123 and 00501.
  6. Select Transform Data to inspect the table before loading.

These controls are documented in Microsoft's Excel import guide and Text/CSV connector reference. The latter explains that disabling detection makes all columns text.

In the editor, check the headings. If customer_code and postal_code are still the first data row under generic column names, select Home > Use First Row As Headers once. If they are already headings, leave them alone. See Microsoft's header instructions.

Confirm that the code values are intact, then choose Home > Close & Load. Microsoft documents closing and loading the query.

For a real file with quantities or prices, this all-text import is a conservative starting point. Decide separately which columns need numeric calculations; preserve identifier columns as text.

3. Compare the finished result

The sample should produce these two columns and three data rows. This is the expected result for the fictional input, not a recorded Excel test.

Customer code Postal code
00123 00501
00007 02108
04210 10001

Select individual cells and compare their full values in the formula bar with the source file. Check all six sample values, not just the first row. Every sample code contains five characters.

A five-digit display alone is not sufficient: a custom format can make a number look padded without making it a text identifier. Microsoft distinguishes text values from custom number formats.

4. Save the workbook and check any exported CSV

Use File > Save As, or Save a Copy, and choose Excel Workbook (.xlsx) for the working workbook. This format preserves workbook data and formatting, as described in Microsoft's file-format comparison. Keep the original source too.

If another service needs a CSV, save a separate CSV copy from the intended worksheet. Text/CSV export removes formatting and saves only the active sheet; review any format-loss warning before continuing. See Microsoft's text and CSV saving instructions.

Open that exported file in a plain-text editor and check the actual code characters. If you later inspect it in Excel, import it as text again. A CSV does not retain your workbook's cell-format settings, so double-clicking it can trigger conversion again.

Optional: change direct-opening behavior

In Excel for Microsoft 365 or Excel 2024, Windows users can open File > Options > Data > Automatic Data Conversion and clear Remove leading zeros and convert to a number. This keeps incoming values with leading zeros as text in the operations covered by that setting.

This is a separate option from the import method above. It does not directly control Power Query imports, and it does not repair previously changed data. Microsoft's automatic-conversion guide lists the supported editions and scope. If the option is missing, use explicit text import.

If the import controls are different

Use the legacy Text Import Wizard

  1. Open File > Options > Data. Under Show legacy data import wizards, enable From Text (Legacy) and confirm the change.
  2. Select Data > Get Data > Legacy Wizards > From Text (Legacy), then choose the file.
  3. In step 1, choose Delimited and start at row 1. Continue to step 2, select Comma, and clear other delimiters for this sample.
  4. In step 3, select each of the two columns in the preview and choose Text for each. Check both column headings show Text.
  5. Select Finish, choose the destination worksheet cell, and confirm with OK. Compare the resulting values with the table above; the first source row supplies the column names.

Microsoft documents the wizard, enablement path, and per-column Text choice. If the wizard is unavailable too, stop rather than accepting a conversion you cannot verify.

Zeros still disappear

  • Everything lands in one column: return to the import preview and select the file's actual delimiter. The sample uses commas; another export may use semicolons or tabs.
  • The source has zeros, but the preview does not: restart from the untouched copy with type detection disabled, or use the wizard's Text format. Changing a cell to Text afterward cannot recreate missing characters.
  • The original has lost digits: request another export. A code that was shortened or rounded cannot be reliably reconstructed from its remaining digits.
  • Long IDs have changed: Excel numbers have only 15 significant digits of precision. Keep longer identifiers as text from the start, as explained in Microsoft's leading-zero and large-number guidance.

The final check is the same for every route: compare complete identifiers with the untouched source, then check the file you will actually send or upload.

Sources & verification

This guide is based on the documentation below. The instructions have not been independently tested in a live account or on every device.

What to keep in mind

  • Instructions were checked against Microsoft documentation on October 23, 2026. No hands-on Excel test was performed; the fictional sample and expected table are illustrative. The walkthrough targets desktop Excel for Windows, with Microsoft 365 and Excel 2024 as its main scope.

Prepared with AI assistance and reviewed against the listed sources. How we write and verify guides.