Keep leading zeros in Excel.
An identifier such as 00123 is often a label, not a quantity. When Excel interprets it as a number, its numeric value is 123. A CSV contains text, but it does not force Excel to use a text cell type.
Start with the original CSV
- Keep an untouched copy. Avoid double-clicking the only copy and then saving over it.
- Open a blank workbook. In supported desktop versions, choose Data → From Text/CSV.
- Select the actual delimiter. Open the transformation/import preview and set the identifier columns to Text before loading. Check for an automatic “Changed Type” step; remove or edit an incorrect conversion before it loses information.
- Check a few known IDs against the original file before saving the workbook.
Microsoft 365 also offers Automatic Data Conversion settings in supported versions. The setting’s location and availability vary. Check Microsoft’s instructions for your version rather than assuming every Excel release behaves the same way.
Why formatting afterward is different
A custom number format can display a known number of leading zeros, but does not necessarily restore the original identifier. If you do not know how many zeros were present, go back to the source. Adding quotation marks in CSV alone is not a reliable instruction to Excel to keep a cell as text.
Microsoft: keeping leading zeros and large numbers. This utility does not recover a value already changed by another application.
Also read: long identifiers and the precision limit.