How to use the Fix Leading Zeros in CSV
- 1 Drop the file on the studio, or try the example. Check that zero-padded columns still show their zeros in the preview.
- 2 In “Set column types” mark the identifier columns (postcodes, phone numbers, member ids). The studio already guesses these.
- 3 If the zeros were lost earlier, add “Restore leading zeros” and enter the total length, for example 5 for a zip code.
- 4 Export as Excel (.xlsx), which stores identifiers as text.
Why the zeros vanish
A CSV file stores 01234 as the five characters it is. The trouble starts when Excel opens it: it decides that a column of digits is numbers and shows 1234. The file itself was fine; saving it from Excel then writes the shortened value for good. Excel has no per-column type in a CSV, so there is no setting in the file that prevents this.
Three fixes
- Export as Excel instead. An .xlsx file can say that a column is text. The studio writes identifier columns as text cells, so the zeros stay. This is the reliable route.
- Import in Excel as text. In Excel, use Data → From Text/CSV and set the column to Text before loading. Microsoft describes the import options in Import or export text (.txt or .csv) files.
- Restore the zeros. If they were lost already, the “Restore leading zeros” step pads values to a fixed length – useful for zip codes and ids that all have the same length. It never shortens a value.
Identifier or number?
Columns are classed from their values: digits with a leading zero, numbers of 16 digits or more (which a spreadsheet cannot hold exactly), and columns named like zip, postcode, phone or id are treated as identifiers. Anything else made of digits is a number. You can override every column.
Limits
A CSV cannot carry the information that a column is text, so no CSV export can force Excel to keep zeros; the studio says so when you export identifier columns as CSV. Padding assumes a fixed length: a variable-length id cannot be restored.
Frequently asked questions
Can I keep the leading zeros in a CSV that Excel opens?
Not reliably. Excel decides itself when it opens a CSV. Export as .xlsx, or import the CSV through Data → From Text/CSV and set the column to Text.
My zeros are already gone. Can I get them back?
If every value should have the same length, yes: use “Restore leading zeros” with that length. If lengths vary, the information is lost.
Are long numbers like 16-digit card or account numbers safe?
Excel keeps only 15 significant digits of a number, so such values must be text. They are treated as identifiers and written as text.
Last updated: