Save as csv number formating issues

csguru01

New Member
Joined
Jul 27, 2012
Messages
2
Hi,

I'm doing a bunch of data massaging of excel files to get to a point where I can import into a different program. The import data needs to be in .csv format.

No matter what format or process I try trailing zeros are getting removed when i save as the csv.

Data in .xls prior to save:

1.10 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS
1.20 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS
1.130 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS
1.140 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS

When I save as csv they are getting changed to

1.1 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS
1.2 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS
1.13 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS
1.14 LOTS AND LOTS OF TEXT GOES HERE FOR IMPORT PROCESS

I have done the process numerous times and it always works (sometimes 2-3k Rows of info) with the exception of anything that ends in a zero.

Any ideas?

Thank you in advance.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
No matter what format or process I try trailing zeros are getting removed when i save as the csv.


Not when you save. Confirm by opening the CSV file in Notepad.

When we save As CSV, data is written as they appear in the cells.

(Except for numeric data formatted as General. But in that case, the trailing zeros would not appear in the cell, either.)

However, if you open the CSV file directly in Excel, then yes: trailing zeros will not appear in the cells because they are usually formatted as General.

(Except if Excel recognizes the CSV data as a percentage or currency, and they were saved in the CSV file with up to 2 trailing zeros.)

Work-around (sigh, not a good one).... Do not open the CSV file directly in Excel. Instead, import the CSV File (Data > Get External Data > From Text), and in the last dialog box, select Text for the column.
 
Upvote 0
Errata....
Work-around (sigh, not a good one).... Do not open the CSV file directly in Excel. Instead, import the CSV File (Data > Get External Data > From Text), and in the last dialog box, select Text for the column.

I wasn't thinking clearly. That is a (not-so-good) work-around for dealing with missing leading zeros, especially for data that is not really treated as numbers (e.g. IDs).

But for non-integer data with trailing zeros, you probably want to treat the data as numbers. In that case, changing the column format to Text has consequences.

Anyway, the important take-away is: the data is indeed saved with trailing zeros. So if the CSV file is read by a different application, it will see the data as intended. Again, confirm by opening the CSV file with Notepad.
 
Upvote 0
Solution
Confirmed and correct. Opening in word the zeros are there. I can modify my process based on this so I'm good but really surprised there is not a way to overcome... I wonder if any of the spreadsheet clones might work differently.

So not necessarily a solution but it is a resolution so tip of the hat to joeu!!

Thank you
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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