Include leading zeros in a CSV file without importing

2.3k views Asked by At

I have code that creates a csv mailing list for use in Excel 2013. My problem is that when the csv is clicked to open in Excel, the leading zero on zip codes is removed.

In older versions of Excel, you could add a single quote to denote that the cell should be treated as a string, but in the newer versions, the single quote is included. I've also tried double quotes and enclosing the zip code in single and double quotes with no luck.

I know that you can change the csv to a text file, and then manually import it into Excel, setting the zip column as a text column, but I would prefer make it easier on the end user.

Is there a way to import a number as a string from a csv in Excel 2013?

1

There are 1 answers

6
M463 On

EDIT: As stated in the comments above, there is also a solution on the exporting side.


Instead of just opening the .csv-file with excel, have you tried a import, using Data > Import external Data > From Text?

Data Import Ribbon

There you will have to option to select a dedicated text qualifier, that can be your single quote '

Data Import Options 1

Just make sure to choose Text as column type for the column, you need leading zeros in.

Data Import Options 2

This would be the result:

Data Import Result

Sorry for the german screenshots, but you live where you live. ;-)