Lost precision when saving csv to excel format - 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.

You don't say what version you're using, but the following seems to work in Excel 2007:
Use Data ... Get External Data ... From Text Select your file and
click "Import"
In Text Import Wizard Step 1, set Original Data Type
to "Delimited" (the default on my installation)
In Text Import Wizard Step 2, select your delimiter (my test file uses Comma)
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"
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

Related

How to import CSV-file with Microsoft Excel 2016?

I try to import a CSV-file in Excel. The program has funny default properties. It puts the content of the rows all in one column including the commas. Lets say the file content is (test.csv):
1, 2, 3
4, 5, 6
What I expect Excel to do is to put each number into a separate field using the comma as separators. However, the excel table has only two fields each containing 3 numbers including the commas, something like this (not what I want):
"1, 2, 3"
"4, 5, 6"
What do I have to change in Excel settings so that it does this standard task correctly?
You are probably not importing the CSV but instead opening it either double clicking or using the open dialog.
One of the correct ways of importing a CSV into Excel is using Data | From Text/CSV menu. This way you will be able to select the delimiters, change data types if you need etc.
Importing CSV via Data | From Text is -- altough working -- rather cumbersome: You need to select the file, the wizard asks about "Delimited" or "Fixed width", then you need to select "Comma" as seperator and finally how to import the data. And when you want to reimport later on the whole procedure starts again and again and again ..
Instead use Data | New Query | From File | From CSV and select the file to import from. I still had to adjust the encoding to UTF-8 while other settings are correctly detected (delimited by comma).
The really great advantage is that you have to do this only once as the above procedure creates a so called "workbook query". To update or reimport just click "Refresh" in the workbook query's context menu.
Depending of the configuration of Excel, the CSV files can be separated with "," or ";". To open a CSV file it's better to go to file-->open file-->text. There Excel asks you for the way you want to separate your fields in CSV.
Regards

Excel 2010 - load a text file "as text"

Is there anyway I can get Excel 2010 to load a text file as pure text, i.e. apply no interpretation to any field? I need to modify a large CSV file with several hundred columns (basically remove some columns). It's health data, so some of the columns are:
NHS number "123456789012", which Excel displays as 1.23E09
Hospital ID: "0123456", which Excel displays as "123456". The leading zero is important here.
Various 2 char status codes where the leading zero is imports, i.e. "01" does not mean "1".
I don't want to have to go through all 297 columns reformatting them correctly. Please help!
From main menu Data select From Text (or similar. I don't know if it is the correct label in English Excel version. On my version it is the third button from left on the Data ribbon).
Then choose your csv file. You will get a wizard where you have to choose the column separator character and especially the import format of the columns. Here you should select all columns and then choose the radio button 'Text'. This should import all data as plain text.

Importing CSV into Excel: import wizard fails to recognize text qualifier but opening directly in Excel converts to scientific notation

I receive a csv file periodically from a database download and I cannot change the way this csv file is produced. I need to convert it to an Excel file to pass it on to an external partner. There are two fields causing trouble in the csv file when I import into Excel: a permit number which is actually a character string, and a location description which can contain commas and other punctuation.
If I right click on the csv file and select Open With Excel, the location description is imported correctly but some permit numbers are converted to scientific notation.
Alternatively, if I use the text import wizard in Excel, I can import the permit numbers as text, but the location description ends up being split across multiple cells even when I set the text qualifier to ".
Here is a simplified example of the data as it appears in the csv file:
id, "Permit Number", Species, Longitude, "Location Details"
1, 2F66-16, DE, -120.0001, "near a road, in woods (FR16)"
2, 678E-15, DE, -120.0002, "near milepost 65, north side of road"
Is there a solution that will allow me to import both fields correctly? This question is very similar but has no answers:
excel text importing: wizard vs opening a file within Explorer
Thanks for any help.
Update: I think the Location Description is being split into multiple cells because of line breaks in the csv. I'm not sure how these are being generated or how to remove them or deal with them, but when I open the file in Excel, the line breaks are still there (although the entire location description is in one cell). Unfortunately I can't post the full example data because it is sensitive data not easily converted to dummy data. Any thoughts on how to remove line breaks from a csv file?
For whatever reason, Excel doesn't seem to like spaces between the comma and the quote. If you do a global find and replace on your input data (change comma-space-quote to comma-quote) -- and then parse your data, it will honor the text qualifiers as you need.
id, "Permit Number", Species, Longitude, "Location Details"
1, 2F66-16, DE, -120.0001, "near a road, in woods (FR16)"
2, 678E-15, DE, -120.0002, "near milepost 65, north side of road"
You are on the right track using the text import wizard within Excel, that at least gives you more control.
I don't know why the text qualifier isn't working, that's exactly what it is designed to do.
Are you specifying that final column as TEXT instead of leaving it as GENERAL?
Do the sample items in the wizard show correctly?
Are you positive they are " characters, and something similar (like smart quotes)?
It's a pain, but if nothing else works, you can always combine the columns back together at the end:
Insert a column before your broken up details
Add a formula like =E2 & "," & E3 (or longer if it splits into more than two)
Copy the combined column, then paste values (over the same cells)
Delete the now extraneous columns
Was able to do it with the text importer:

Excel converts document exported from google keyword tool numbers into dates

When I import document from google keyword tool some curency values are converted to date for example 5.21 is converted to May 21. However there are some in the same column that are not conveted. What should I do that my document would not be disorted ? Tried to remove text proofing when typing, however I have document prewriten by google so it dosen't help.
Your regional settings seem to have the dot in the date format, with an order of MDY, so Excel will interpret a number like 5.21 as a date, but a number like 5.66 will remain a number.
Try exporting the Google output to a text file. Then open the text file with Excel via the File > Open menu. This will bring up the text import wizard. In Step 3 of the wizard you can select each column of data and specify what data type it contains, i.e. to tell Excel what each column contains.
You regional settings may also be set to have a comma as the decimal separator. In this case, Excel will not recognize 5.21 as a number at all. You can
change the Google output to produce numbers like 5,21 or
temporarily change your regional settings to use the format Google serves you
mark the column as text and import it as text, then use find and replace on that column to replace the decimal character with the one your system uses.

CSV file creation without exponential numbers

How do you get around the exponential conversion that takes place when inserting a value into a csv file. I have a process that creates a csv file and then starts entering rows into it. One of those fields inside a row inserts a value similar to this:
123,45,45,466,6656,23423,2455,234,2454
These are just a string of id's i need to preserve on the csv file in order to import them into another program that expects a comma separated number of values in this field.
Of course when i open excel and look at this csv it gives me something like this:
123,45,45,466,6656,000,000,000,000
so those last few values mean nothing to the import process and it fails.
My question is how do i write to a csv file and get around my values being converted to exponential numbers as well as preserving the comma separated number values like above?
Thanks in advance
Billy
Put quotes around them
"123","45","45","466","6656","23423","2455","234","2454"
In order to get around this issue i used the following steps in MS Excel 2007:
Open a Blank Workbook in Excel.
Choose Data, Get External Data, Import Data. (Excel 2007 is Data, Get External Data, Data from Text)
Browse to your .csv file and Select "Import".
Import Wizard should appear.
Page 1 Select "Delimited"
Select the row which you want to start the import.
click "Next"
In the Delimiters, select "comma" and/or other delimiters you are using.
Note: The bottom half of the window will preview the way the data is to be imported.
click "Next"
highlight each column of your data in the window below. For each column you can specify "General", "Text", "Data", or "do not import column" using the radio buttons in the top left of the Wizard box. I used the "Text" option. This is an optional step.
Click Finish.
place the value in single quotes while using data
Eg:
String[] abc = {"0123455677888", "154758768969", "abcsdhfsdj", ""abcsdhfsdj3725423", "62343664268abcsdhfsdj"};
CSVWriter csvWriter = new CSVWriter(String fileName);
//csvWriter.writeNext(String[] stringArray)
csvWriter.writeNext(" \' "+abc[0]+" \' ", " \' "+abc[1]+" \' ", abc[2], abc[3], abc[4]);
Try this
It will store the data perfectly

Resources