How do you keep leading zeros when you open a CSV in Excel on a Mac?
By Kayabyte · Last updated 4 November 2026
If a ZIP code such as 02134 or an ID such as 00123 turns into 2134 or 123 when you open a CSV in Excel, the zeros were lost when Excel read the column as numbers. Do not double-click the file. Import it instead and set that column to Text before it loads: Microsoft’s own page on importing text and CSV files says you may need the import wizard to “convert a column of numbers that contains leading zeros to text so you can preserve the leading zeros” (support.microsoft.com, checked 4 November 2026). The CSV file itself still has the zeros; the loss happens on opening, and a file saved from Excel afterwards keeps the loss.
Why the zeros disappear
A CSV is plain text with no column types. When you double-click it, Excel decides for each column what it holds. A column of digits becomes numbers, and a number has no leading zeros. The same guess can turn long codes into scientific notation and some codes into dates. Microsoft’s page says Excel applies its default data format settings to each column when it opens a .csv file.
Method 1: import and set the column to Text
- Open Excel first, with a blank workbook.
- Use the import route for text files. In current Excel this is on the Data tab (Get Data, From Text/CSV); older versions start a Text Import Wizard. Menu names vary by Excel version, so look for a “from text” or “import” entry.
- In the preview, set the column that holds the codes to Text, not General.
- Load the data and check a few codes against the original file.
Microsoft’s page also notes that if you rename a .csv file to .txt, Excel starts the Import Text Wizard when you open it. That is a quick way to get the column-by-column choices.
Method 2: fix a column that already lost its zeros
If the codes are already numbers and all have the same length (for example 5-digit ZIP codes), a formula can put the zeros back: =TEXT(A2,"00000") for five digits. Copy the result and Paste Special, Values over the original. This only works when every code should have the same length. For mixed-length codes, go back to the CSV and import it again with the column set to Text.
What to avoid
- Saving over the CSV from Excel after the zeros were lost. The file now contains 2134, and the zeros are gone for good. Keep the original.
- Formatting the column as Custom 00000 when you need the text. It only changes how the number looks. Searching, lookups against text codes and exporting can still see 2134.
- Using text codes in a lookup against a column of numbers. A text 02134 and a number 2134 do not match in a VLOOKUP. See VLOOKUP between two Excel files.
With Gridhand
Gridhand Convert reads CSV, TSV and text files with the encoding (BOM, UTF-8, UTF-16, Windows-1252) and delimiter (comma, semicolon, tab, pipe) detected, and keeps IDs with leading zeros as text. You can drop many CSVs in at once and get one .xlsx per file, with the preview showing the columns before anything is written. Originals are never modified. The same applies in Clean: codes with leading zeros, and codes of 12 or more digits, stay text instead of being turned into numbers.
This page does not cover what a particular version of Excel does with the resulting .xlsx files beyond opening them; check a few codes after opening.
Steps with Gridhand
- Drop the CSV files, or a folder of them, into Gridhand and choose Convert, “CSV, TSV or text to XLSX”.
- Check the encoding and delimiter in the preview, and look at your code column.
- Choose an output folder and press Run.
- Open the .xlsx in Excel and compare a few codes with the CSV.
Free for up to 3 files per run; Gridhand Pro is USD 49 once. Download Gridhand · Pricing
Questions
Are the zeros really gone from my CSV file? Not as long as you only opened it and did not save over it. Open the file in TextEdit to see the raw text.
Why does a number like 12345678901234 show as 1.23457E+13? Excel read the column as numbers and shows long ones in scientific notation. Import the column as Text to keep every digit.
Will Gridhand turn my IDs into numbers? No. Codes with leading zeros stay text, and so do codes of 12 or more digits.
Related guides
- Batch convert CSV files to XLSX on a Mac
- Merge CSV files on a Mac
- Clean data in many Excel files at once
Microsoft and Excel are trademarks of the Microsoft group of companies. Gridhand is made by Kayabyte and is not affiliated with or endorsed by Microsoft.
More guides
- Is there an ASAP Utilities for Mac, and what can you use instead?
- How do you combine multiple CSV files into one Excel workbook on a Mac?
- How do you combine multiple Excel files into one sheet on a Mac?
- How do you compare two Excel files on a Mac?
- How do you convert XLSX to CSV on a Mac, for every sheet and many files?
- How do you find and replace in multiple Excel files on a Mac?
- Gridhand vs Kiolix Xel and SysTools Excel Split & Merge on a Mac
- Gridhand vs XLclick vs XLWizard: which Excel tool for Mac?
- Is there a Kutools for Mac, and what are the alternatives for Mac?
- How do you merge Excel files on a Mac?
- Can you use Power Query on a Mac to merge Excel files?
- How do you remove duplicates from two or more Excel files?
- How do you split Excel data into one file per customer, region or month on a Mac?
- How do you split an Excel workbook into one file per sheet, or every N rows, on a Mac?