Check the original file before changing anything
A postal code may contain leading zeros, letters, spaces or a hyphen. It identifies a destination rather than a quantity for arithmetic. Excel can interpret a numeric-looking code as a number when opening CSV and remove the leading zero. A CSV file does not carry a spreadsheet’s column-type setting.
Open a copy of the export in a text editor and search for the original value. If it still contains 02108, the export and the spreadsheet’s interpretation are different stages of the problem. Keep that original file before making changes.
Original text: 02108 Unwanted numeric conversion: 2108 JSON string: "02108" Hong Kong postal value: ""
Import with a text column
In desktop Excel, start from Data and use From Text/CSV. Select the file, open the transformation view and give the postal column the Text type before loading. If Power Query already added an automatic numeric type step, remove or correct that step first so that the leading zero is not lost upstream. Menu wording varies across Excel versions.
The legacy Text Import Wizard is another route: select the postal column in its preview and choose Text as the column format. CSV quotation marks group field contents; they are not a reliable instruction that Excel must store a value as text.
Reimport damaged values rather than guessing
Changing a cell to Text after a zero has been discarded does not tell Excel what the original string was. Start again from the unchanged export where possible. A fixed-width display format is a limited presentation choice, not a universal recovery method for international postal codes.
In particular, do not pad every destination to five digits. AddressSample supports different national formats, and Hong Kong has no postcode. In JSON, our postal values are strings, including an empty string for Hong Kong; software consuming JSON should preserve that type.
An AddressSample export check
Generate and save a test record with a leading-zero postal code. Open Saved addresses and check the active search and country filters: the export includes visible results only. Export CSV, import the postal field as Text, and compare it with the original value.
Then save the workbook as XLSX if you want to retain workbook column settings. If you export CSV again, reopen that new file in a text editor to inspect its actual values before passing it on. This guide explains an import workflow; it does not mean AddressSample can control the receiving spreadsheet’s automatic conversions.
Sources and further reading
- Microsoft — Keeping leading zeros and large numbers
- Microsoft — Import or export text files
- Microsoft — Text Import Wizard