Komma

Keep leading zeros and long IDs in CSV files on Mac

Leading zeros disappear when an app interprets an identifier as a number. Import product codes and ZIP codes as text, then check that the saved CSV still contains the original digits.

By Komma · Reviewed: · Documentation and October 18 app test reviewed

Check whether the source still contains the zeros

00123 and 123 represent the same number but may identify different products. Keep a copy of the original CSV and inspect it with an editor that displays plain text. If it still contains 00123, you can reopen it with different import settings.

If the file itself now contains 123, that value cannot tell you whether the original had five or six digits. Get a fresh export or compare a previous copy. Changing a rounded long ID to a text format does not restore its lost digits either.

Adjust automatic conversions in Excel for Mac

Microsoft 365 and Excel 2024 for Mac provide automatic data conversion settings.

  1. Open Excel → Preferences → Edit and find Automatic Data Conversion.
  2. Disable removal of leading zeros. For long IDs, also review the conversion that keeps only 15 digits.
  3. Reopen a copy of the CSV that still contains the original values and compare the ID columns.

Names and placement vary by version. Microsoft’s automatic conversion guide lists supported editions and the Mac settings. These preferences do not directly control Power Query imports; those need their own text-column type settings.

Why quotes and formatting are not enough

Quotes in "00123" delimit a CSV field. They do not declare that the column must be text in every receiving app. Keep CSV field syntax separate from an application’s type inference.

Displaying a number with five digits does not ensure another system receives that formatting. Adding an apostrophe or changing the value into a formula can also pass unwanted characters or expressions to the destination. If the required value is the text 00123, preserve those characters and configure the receiving column accordingly.

Test zeros, long IDs and date-like labels

Download the synthetic identifier CSV. Its postal-code column uses five-digit US-style test values.

product_id,postal_code,external_id,date_label,status
00123,02108,12345678901234567890,03-04,review
00456,00501,98765432109876543210,10-11,ready

Change one status cell in a copy, save, reopen and compare all 15 cells. Check every digit of the 20-digit IDs. Then try a small import in the receiving system to check that it does not convert the identifiers to numbers there.

For the overall editing workflow, see editing CSV files on Mac. You can also change the default app used to open them.

Back to CSV editing guides