How to Keep Leading Zeros and Dates When Opening a CSV File

How to Keep Leading Zeros and Dates When Opening a CSV File - CSV Editing


You open a CSV file in Excel and the postal codes have lost their first zero. Product codes like 000123 are now 123. A date written 03/04/2026 has become the 3rd of April when the file meant the 4th of March, and long ID numbers show as 1.23E+15. Save the file, and those changes are written back into it.

This article explains why it happens, the usual ways around it in Excel, and how to keep every value exactly as it is.

Why It Happens

A CSV file is plain text. It has no idea what a "number" or a "date" is: 000123 is just six characters. When you double-click a CSV file, Excel opens it as a spreadsheet and guesses a type for every column. Anything that looks like a number becomes a number (so leading zeros go), anything that looks like a date becomes a date in your regional format, and very long numbers are rounded or shown in scientific notation.

The guess happens before you see the data, and saving the file as CSV writes the converted values back.

Workarounds in Excel

If you need to stay in Excel, these help:

  • Import instead of opening. Use Data > From Text/CSV, then set the affected columns to Text before loading.
  • Rename the file to .txt. Excel then shows the import wizard, where you can choose Text for each column.
  • Change the file at the source, for example by storing codes with a leading apostrophe.

They work, but they have to be repeated for every file and every column, and a single double-click on a CSV file undoes the care.

Keep the Values with a CSV Editor

A CSV editor such as Rons Data Edit treats every value as text. It opens the file as a grid, but nothing is converted: what is in the file is exactly what you see, and what you save is exactly what you edited.

  1. Open the file in Rons Data Edit (drag and drop it, or open it from the program). The delimiter and text encoding are detected automatically.
  2. Check the columns. Postal codes, product codes and IDs keep their leading zeros; dates stay in the format they were written in; long numbers keep every digit.
  3. Edit as needed: sort, filter, fix values, remove duplicates or empty rows.
  4. Save. Values you did not edit are written back unchanged.

To open CSV files this way every time, associate the .csv extension with Rons Data Edit (see How To Configure Delimiters and File Associations).

Changing Date Formats on Purpose

Sometimes you do want to change the dates, for example to turn 03/04/2026 into 2026-04-03 before importing the file into another system. In Rons Data Edit, the Toolbox includes tools for dates, so you can convert a column deliberately, check the result, and undo if needed. Save the steps as a Cleaner to apply the same conversion to next month's file.

Still Need It in Excel?

Clean and check the file first, then export it to Excel from Rons Data Edit (Excel must be installed), or import it into Excel with the columns set to Text.

Rons Data Edit Lite is free with no time limit and saves up to 2,500 rows: download Rons Data Edit.

See Also