Home / Guides

How to open a CSV file in Excel without losing leading zeros, long numbers or accents

Double-click a CSV file and Excel quietly changes some of your data: 00721 becomes 721, a 16-digit ID ends in a zero, a product code turns into a date, accented letters turn into symbols. Here is what Microsoft documents, and how to avoid each one.

What Excel changes when it opens a CSV

Microsoft lists four automatic conversions that Excel applies when "opening a .csv or .txt file":

ConversionExampleWhy it hurts
Leading zeros removed00123 becomes 123ZIP codes, employee IDs, SKUs and phone numbers stop matching other lists.
Long numbers cut to 15 digits1234567890123456789 becomes 1234567890123450000Card numbers, order IDs, tracking numbers and database keys are changed for good once saved.
Numbers with the letter E read as scientific notation1E5 becomes 100000Part numbers and codes that contain an E between digits.
Letters and numbers read as datesJAN1 becomes a dateProduct codes and, famously, gene names.

The 15-digit limit is Excel's number precision: Microsoft says that "for any number containing 16 or more digits, such as a credit card number, any numbers past the 15th digit are rounded down to zero." Excel stores numbers with 15 digits of precision whatever the file says.

In Microsoft 365 and Excel 2024, each conversion can be switched off in File, Options, Data, Automatic Data Conversion. Older versions do not have the setting, so use the import method below.

The safe way to open a CSV in Excel

  1. Open a blank workbook. Do not double-click the CSV file.
  2. Go to Data, Get Data, From File, From Text/CSV (in Excel 2016: Data, From Text) and choose the file.
  3. Check the preview. Set File Origin to 65001: Unicode (UTF-8) if accented letters look wrong, and the delimiter to comma or semicolon.
  4. Choose Transform Data and set the columns that hold IDs, codes or ZIP codes to Text before loading. Text columns keep every digit and zero.

Accented letters that turn into symbols

A CSV file is plain text, and Excel has to guess its encoding. Microsoft's page on UTF-8 CSV files says you "can open a CSV file encoded with UTF-8 normally if it was saved with BOM (Byte Order Mark)"; otherwise, use Data, Get Data, From Text/CSV. The byte order mark is the invisible character U+FEFF at the very start of the file. Files saved from Excel as "CSV UTF-8" have it; files exported by many web apps do not. The CSV files downloaded from the tools on this site include it, so they open correctly with a double-click.

The same mark causes the opposite problem elsewhere: a program that does not expect it may read the first column name as \ufeffEmail instead of Email. If a column "does not exist" although you can see it, check the start of the file with the hidden character detector.

Comma or semicolon?

Excel uses the list separator of your computer's regional settings. Microsoft: "When you save a workbook as a .csv file, the default list separator (delimiter) is a comma", and after you change the list separator for your computer, "all programs use the new character". In countries where the comma is the decimal mark, the list separator is usually a semicolon, so a CSV saved there has semicolons and a CSV from elsewhere opens with everything in one column. The import method above lets you pick the delimiter, and the CSV viewer detects it automatically.

What the CSV format allows

There is no official CSV standard. The common reference is RFC 4180, published in 2005 as an Informational document, which also registered the text/csv media type. Its rules:

  • One record per line, lines ending with CRLF; the last line may end without one.
  • An optional header line with the same number of fields.
  • Fields separated by commas. Spaces are part of the field.
  • A field that contains a comma, a double quote or a line break should be enclosed in double quotes.
  • A double quote inside a quoted field is written twice: "She said ""yes""".

Real files break these rules all the time: semicolons instead of commas, missing quotes around a comma, a byte order mark, mixed line endings. A good reader should cope with all of them; the CSV viewer and text to columns on this site follow RFC 4180 and also accept semicolons, tabs and | bars.

Check a CSV before you open it in Excel

  • Open it in the CSV viewer: it shows every value exactly as written, with leading zeros and all digits.
  • Sort a column to spot values that look like dates or numbers but should be codes.
  • Paste one suspicious cell into the hidden character detector if two values that look the same do not match.

Tools for this

Sources