Save an excel file to a csv and retain leading 0's

tbrynard01

Board Regular
Joined
Sep 20, 2017
Messages
129
Office Version
  1. 365
Platform
  1. Windows
I have an excel file that I downloaded from our donor software, I added leading zeros to zip codes by adding ' in front of the number but when I save it as a CSV (which is what I need to import back into the donor software) it loses the leading zeros, how can I stop that from happening? Thanks.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
The leading 0s should still be there, try opening the csv in a text editor, such as notepad, to check.
It's only when you open it in xl that you will loose the leading 0s.
 
Upvote 0
It is there in the text file, but I need a csv to import it back into my donor software and I need to retain the leading zeros on zip codes?
 
Upvote 0
If the software you are loading into is stripping out the 0s then you need to look at that software. It has nothing to do with the csv.
 
Upvote 0
I don't understand. The software will import what is the there. The problem is when I save the excel file as a csv and then open the csv file the leading zeros are gone
 
Upvote 0
You said that the leading 0s are in the csv if you open it in notepad. Which means there should not be a problem unless the other software is removing them.
Do NOT open csv files in xl, either import them or use a text editor.
 
Upvote 0
I apologize, I added the leading zeros in the xlsx file, but of course when I save as csv it drops off the leading zeros. I created a text file but when I go to Data/From Text/CSV i don't get the wizard where I can specify to make that column text?
 
Upvote 0
Glad it's resolved & thanks for the feedback.
 
Upvote 0
I apologize, I added the leading zeros in the xlsx file, but of course when I save as csv it drops off the leading zeros. I created a text file but when I go to Data/From Text/CSV i don't get the wizard where I can specify to make that column text?
That is not the case.
As fluff was telling you, you need to use a Text Editor like NotePad to view the actual contents of the CSV file. What you see in there is what really is in the CSV.

When you use Excel to view a CSV file, Excel automatically does its own conversions on the file, dropping leading zeroes off of numeric values. So opening it Excel does NOT give you an accurate representation of what is in the CSV file.

I usually advise people, NEVER use Excel to view the contents of a CSV file, as it may not be an accurate representation.
One of my biggest pet peeves is that Microsoft sets Excel to be the default program to open CSV files. Its a horrible choice for that (for the issues explained above)! This is usually one of the first things I change when I get a new computer.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top