Forum Discussion
CSV file is dropping zeros on zip codes when imported
ABcomputer Try importing the file. Do NOT open it directly in Excel by double-clicking it, as Excel will then assume that the zip codes are numbers and thus drop all leading zeroes.
Importing can be done in different ways. On the Data ribbon, Get Data, CSV/TXT (i.e. Power Query) or Get Data, From Text (Legacy).
I suspect you are not familiar with Power Query. Otherwise, you would not have asked the question. So, let's go for the From Text (Legacy) option. It opens a window, just like the one in Text-to-columns. Follow through steps 1 and 2 to create separate columns (probably Delimited, Comma). In step 3 of 3, in the preview box, select the column with the zip codes and explicitly set the data format to Text.
Press Finish. Now your CSV data should be neatly organised in columns with the leading zeroes of the zip codes preserved.
Here is what I did-
Data-> From text/CSV-> Selected the file-> Transfrom -> selected the column-> on the transform ribbbon data type= text-> Close and load-> I get an excel sheet with the zeros -> save as csv and the zero are lost again
- Riny_van_EekelenJan 17, 2023Platinum Contributor
ABcomputer You went for the PQ solution anyway. You'll find he Finish button in the Text import option.
Anyway, you managed to import the numbers with the leading zeroes. And you say that when you save the file as a CSV, the leading zeroes disappear. I've never tried to do this myself and can't explain what's happening. Saving as a CSV should just create flat text. No formatting or intelligence whatsoever. But perhaps I'm wrong.