How do I keep leading zeros when importing a CSV for shipping or inventory?

Read identifiers as text before the spreadsheet converts them. Check the raw file first, set the column type during import, and test the exported value in the receiving system. ZIP Codes and customer IDs often look numeric even though their exact characters matter.

Auf Deutsch lesen

Step-by-step walkthrough

  1. Make a tiny file with the headings order_id,zip,units and two data rows. In a plain text editor, record the spelling of both order IDs and both ZIP Codes.

  2. Use the spreadsheet's text/CSV import workflow. In Excel's transform preview, set order_id and zip to Text, keep units numeric, and check whether a prior automatic type step needs to be replaced.

  3. Load the records and search for each complete ID. Check that the displayed ZIP and the underlying value both match your raw sample.

  4. Write a new export. Read it as text first, then use a test import in the receiving application. Inspect the saved record before processing the full file.

Free practice example

Try the records 00012,02108,4 and 12,94103,7 under the sample headings. A successful round trip preserves two different IDs and the first ZIP's initial zero. A lookup for order 00012 returns four units, even though a numeric comparison might treat both orders as number twelve.

How to check your result

Count data rows, compare field lengths, and inspect the full strings. A file can preserve the row count and still swap units between orders when two distinct keys collapse into one.

Questions you can work through

What should I inspect before blaming Excel for a missing zero?

Open the received file in a text editor and locate the precise record. If the sender already exported 2108, ask for the original ZIP field or a corrected export.

Will wrapping the value in double quotes force every importer to keep it as text?

Quotes delimit fields in CSV. Different readers still infer types. Explicitly set the destination column to text and verify the result in that reader.

Why is converting the column to Text after import too late?

The reader may already have converted 00012 into numeric 12. A new text value of “12” has no record of how many zeros went missing.

How can I test whether two order IDs collapse in a join?

Include deliberately distinct keys such as 00012 and 12 on both sides of a small test join. Each should match just its own row with its expected quantity.

Should I add an apostrophe to every ID before handing off the CSV?

An apostrophe may become a literal character in another application's key. Prefer an agreed text field and confirm a clean round trip with the receiving team.

What about ZIP+4 values in the same column?

Use text for the whole column and keep the hyphen where the receiving specification requires it. Check a five-digit example and a full ZIP+4 example separately.

How should I handle a 17-digit shipment reference?

Import it as text from the original file. Excel's numeric precision can lose digits on long numbers. Compare the suffix as well as the prefix.

Can I safely pad all short records with zeros?

Only if the identifier's authoritative specification fixes its width. Order IDs and postal codes may follow different rules even in the same export.

How do I know whether the destination strips zeros on save?

Reopen the saved test record or export it back out and inspect the stored ID. The import preview alone may not represent what the destination persists.

How can I share the bug with support without sending customer records?

Send a small invented file with the same delimiter and field types, the import steps, the expected value, and the actual value. Keep original customer data out of the sample.

Frequently asked questions

Can I do the first check on a Mac?

Yes. Any plain text editor that shows the raw file contents lets you inspect the characters before import.

Does sorting prove an ID survived?

No. Compare the complete identifier with the original and check that the correct row still joins to it.

What should go in our handoff instructions?

Identify the text fields, delimiter, two regression records and expected results. Note the receiving application and the import path used.

Sources

Checked

Continue with the masterprompt

Original product files are in German. EUR 17.50 one-time.

✪ AISECRETS™ SPREADSHEET INTELLIGENCE™ (German product page)

Follow guides via RSS

Help & FAQ