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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

joeu2004

Banned user
Joined
Mar 2, 2014
Messages
3,080
Office Version
  1. 2010
Platform
  1. Windows
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.
 

joeu2004

Banned user
Joined
Mar 2, 2014
Messages
3,080
Office Version
  1. 2010
Platform
  1. Windows
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.
 
Solution

csguru01

New Member
Joined
Jul 27, 2012
Messages
2
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
 

Forum statistics

Threads
1,141,068
Messages
5,704,099
Members
421,327
Latest member
Msh

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
Top