Excel changes SKUs in a Magento 2 export. How do you keep leading zeros and exact IDs?

2 min read

Rows of silver tiles with leading zeros held in place by a burgundy clamp

A catalog can contain both 123 and 000123. If Excel reads the second SKU as a number, both can end up with the same code in the saved CSV. Keep the downloaded file as your reference and import the SKU column as text.

Start with the contents of the CSV

Open a copy of the download in a text editor and locate the sku column. In the 1.0.8 test export, commas separated the fields and all five codes below stayed intact. CSV carries no spreadsheet column types. Exporter documentation.

Five sample SKUs and their expected text values
SKUWhat to checkExpected text
000123Leading zeros000123
123Distinct control code123
12345678901234567All 17 digits12345678901234567
1E5Looks like scientific notation1E5
01-02Looks like a date01-02

Set the SKU column to Text before loading

  1. In Excel, choose Data → From Text/CSV and select the original file. In the preview, confirm the delimiter and check that SKU has its own column.
  2. Turn off data type detection if the preview offers that setting. Otherwise, open the Power Query Editor, remove the automatic Changed Type step and set the SKU column to Text before loading.
  3. Match the five values to the table before loading the worksheet. If a code has already lost digits in the preview, start from the original CSV and correct the query steps.

Keep identifiers as text in Excel and control type detection in Power Query.

Check a new copy after editing

If you need another CSV, save it under a new name. Parse both files with their respective delimiters and compare the SKU column values and row counts. Count occurrences of each code. In a deliberately altered sample, 000123 vanished and 123 appeared twice. Applying catalog changes requires a separate importer with its own file format and validation rules.

Export selected attributes to CSV · Pre-export checklist for Magento 2.

Previous Next

KOWAL.BLOG

Choose your language

Available versions open the corresponding page. More languages are being prepared.

English (UK) Français Deutsch Español Italiano Português Nederlands Svenska Dansk Norsk Suomi Lietuvių Latviešu Eesti Čeština Slovenčina Magyar Română Български Ελληνικά Slovenščina Hrvatski Polski English (US)