Leading zero in CSV

Kyosti

Board Regular
Joined
Jun 2, 2008
Messages
90
So I have tried so many different ways before reaching out to you guys. Is there anyway to have a CSV file with leading zeros in a number field that will not drop the zero when reopening the file?!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I've been through this nightmare many times because Excel thinks it's smart and converts the value to a number that doesn't, of course, have leading zeros.
The workaround I ended up using was to convert the cell(s) to text and put a leading zero.
 
Upvote 0
Leading zeros are not part of a value, but a formatting convention. To be able to retain the leading zeros, bring the value in as text.

Just because a "Number" looks like a number and is referred to as a number does not make it a number.
Example, a credit card number is 16 digits. It is not a number but an account identifier because there are not "credit card numbers" from 0000 0000 0000 0001 to 9999 9999 9999 9999.
This occurs in many instances. Part "numbers", Employee "numbers", Invoice "numbers"
 
Upvote 0
Yeah the only problem is that in reopening the file after making it a text format, Excel in its infinite wisdom drops the 0 again!! I truly hate CSV formatting anyway, but thankfully the automatic upload of the file that is in place reads the 0 as long as when I open the CSV in notepad the 0 is there. So I actually don't need to worry about how Excel opens it. Thanks all!!
 
Upvote 0
CSV is not truely a native Excel format. It is often set up as to be opened by Excel directly, but rarely should. Excel assumes the data import with the data type of General.
Excel's "new" tool, Get and Transform is much better in handling the import of files. You can option to use the old Import method which has also seen some improvements. These tools allow the ability to control exactly how a piece of data is read from a file.
I like the ability to work with CSV or TXT files, but there are certain limitations and gotcha's to be careful of.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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