Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lost precision when saving csv to excel format

Tags:

csv

excel

I have a CSV file, in which one column is storing some account number text, like 99010124450000237, however when i try to save it to excel, it always format the number to 99010124450000200, the last 2 digits are rounded. this is so annoying, because actually i just want the account number be text field, but Excel will always take it as a number, and even worse, it was rounded. anybody have the same pinpoint and maybe some suggestions?

I tried to format the column to a specific format, and tried to import data. neither method works.

like image 499
Liang Zhang Avatar asked Mar 07 '26 21:03

Liang Zhang


1 Answers

You don't say what version you're using, but the following seems to work in Excel 2007:

  1. Use Data ... Get External Data ... From Text Select your file and click "Import"
  2. In Text Import Wizard Step 1, set Original Data Type to "Delimited" (the default on my installation)
  3. In Text Import Wizard Step 2, select your delimiter (my test file uses Comma)
  4. In Text Import Wizard Step 3, click on the column with the account number (it should be highlighted) and change "Column Data Format" to "Text"
  5. Click "Finish"

I used a file with the following text, selecting the second column to be Text:

"99010124450000237",99010124450000237,"99010124450000237"
99010124450000237,"99010124450000237","99010124450000237"

and got this output:

         A                 B                     C
1    9.90101E+16    99010124450000237   9.90101E+16
2    9.90101E+16    99010124450000237   9.90101E+16
like image 120
Mike Woodhouse Avatar answered Mar 09 '26 10:03

Mike Woodhouse