Excel imports numbers with negative exponent incorrectly - excel

For an analysis I am doing I want to look into my data (space-delimited text file) using Excel, for a better overview. I have some really small numbers in that file (1.08675e-06).
Now I am using the Excel import function, select the file and import with delimited with tab + space.
When I look up the same row, the number which was (1.08675e-06) in the text file, is 1,09E-01 in the Excel file.
How is this possible and maybe even more important, how do I make Excel get the right number, instead of the wrong one?
I've already tried changing the "decimal separator" in the "advanced text import settings" in the import settings, which does not seem to work. If someone has an idea, I would love to get some feedback on this problem.

I assume your Windows Regional settings have the dot as the thousands separator and the comma as the decimal separator. In Excel, on the Advanced tab of the text import wizard, you need to change both of these -- not just the decimal separator.
Once you do that, the data should import properly. But, at least in my version, the cell is formatted with just two decimal places. However, the formula bar does show the correct value.
You can easily add decimal places to the formatted number.
An alternative would be to change your Windows Regional Settings with regard to the decimal and thousands separator.

Could you create a mirror and edit the csv file with notepad and replace dot (.) for comma (,) and try again? The problem appears decimal separator in csv file.

Related

Opening CSV files in Excel 2016

I have a new install of Excel 2016, that hates CSV files. It opens them with everything in one column flagpole style, down column A, with commas and speech marks visible.
Salient points:
I have two machines, desktop and laptop, both running same version of Excel. Desktop works fine, opens the same problem files formatted correctly.
I can create CSV files on laptop, save those, open them again on laptop, and it's fine.
Even opening it in Notepad++, saving in the hope of some sort of file format normalisation, and still no good.
I have compared regional settings and almost all settings in Excel.
I tried renaming the file to TXT, it brought up the text file conversion dialogue, I chose comma delimited. First time it ignored that, still got everything in column A, second attempt, that actually worked, however, that is a pants solution, I want to be able to just natively open CSV files without saving as TXT, I use many different ones every day.
Anyone got any ideas?
Thanks in advance.
CSV files are character separated value files, not necessarily comma separated. For more than half the world the separator character is a semicolon (;), not a comma (,)
Excel 2016 properly respects your Windows regional settings, and uses the specified List Separator character
One solution is to change your regional settings for the List Separator attribute to the character you want Excel to default to using, e.g. a comma (,)
This can be changed in the operating system Control Panel, under Region settings, Additional Settings, List separator
For various reasons some people seem to have the incorrect regional settings for the culture they most commonly work in, and therefore have semicolon as the default separator
If you prefer not to change your operating system regional setting to what you think is normal for CSV files, you can change the default behavior in Excel with the Use system separators checkbox under the File/Options/Advanced menu
If you want custom options each time you open a CSV file, use the Data/From Text menu, but this becomes slow and awkward for lots of files
CSV References:
https://en.wikipedia.org/wiki/Decimal_separator (see map of world using comma as decimal point separator, it's very common, and hence CSV's often use semicolon separators)
https://data-gov.tw.rpi.edu/wiki/CSV_files_use_delimiters_other_than_commas
https://en.wikipedia.org/wiki/Comma-separated_values (spec point 3)
https://ec.europa.eu/esco/portal/escopedia/Comma-separated_values_%2528CSV%2529
https://parse-o-matic.com/parse/pskb/CSV-File-Format.htm
I've found a way of saving messy CSV files into a nice table format but I'm not sure if it will work for your case.
Data -> New Query -> From File -> From CSV
By opening the CSV file this way, a pop-up 'Query Editor' window will appear with a nicely organised table format where you can edit, save and load into your excel sheet.
I hope this helps.
For me the solution was to:
Data > From Text > Choose your csv file
Then you can define all the import settings for csv files.
I found another way to fix this, without changing your windows local settings.
In Excel, you go to File > Options > Advanced.
Un-check the "Use System Separators" within the Editing Options and change the Decimal separator with "," and the Thousands Separator ".".
Even it does look more like a bug than a feature of Excel 2016, it works without changing the Windows Local settings, and it's just a local Excel change.
Just had this same problem. Changing the file extension from csv to txt and opening in Excel brings up the classic wizard so you can map the strings to fields.
The correct answer is to edit your regional settings as suggested above (if a long term change in behavior is desired)
Control Panel -> Region -> Additional Settings -> List separator:
But for my purposes a simple Edit -> Find and Replace using Notepad to replace all commas with semi-colons was a quick and dirty solution that I preferred.
Despite the comment that csv means 'Character Separated Values', in Office 2016 my .csv file association to Excel still says 'Microsoft Excel Comma Separated Values File'.
I have quite a complex csv file where none of the suggestions worked out for me. So I ended up using LibreOffice Calc for the job. It worked like a dream.
I had the same problem, I fixed it in this way (Excel 2020)
Data -> Text to Columns
Now you can configure as you wish the CSV delimiters/endlines...
I had the same issue on Mac OS X El Captain. The answer given here worked for me. Reproducing it here in case the link doesnt work in future:
Close the Excel application
Click on the Apple button
Select System Preferences
Select Language and Region
Click Advanced
Change the Decimal separator from a comma (,) to a full stop (.)
Then click on Ok/Save
Test the Excel import again
When changing the list separator, make sure it doesn't overlap with the decimal symbol and the digit grouping characters. I had to change my list separator to (,) my decimal to (.) end my digit grouping to ('). Now .CSV opens lekker!!!
In my excel, it's: data> get data> from file> from text/csv
Try opening in excel, then using text to columns, based on commas.
You could probably create some simple vba to open it in that way too.

Importing CSV to excel incorrectly (dot and comma issue)

I have csv (tab delimited) file which I want to import. In one column there are numbers which decimal part should be separated by comma.
If there is number 50,59459 when imported it will be shown like 5059459,00000. Although, when in csv file is number like 20.08998 it will be imported fine.
What might be problem with not reading comma separated decimals correctly?
For importing I am using macro found on this page: http://sitestory.dk/excel_vba/csv-file-import.htm
Your regional settings are US. So if you have a csv file showing ,s it will disregard them. That story about local being set to true is just for VBA to pick up the delimiter symbol from regional settings. So you need to change the decimal symbol in regional settings before you import files with European style decimal separators. (or change it in VBA after having done some test on the data)

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.

How to save excel columns with long numbers into csv?

Funny thing when I want to save Excel columns with long numbers like below, resulting csv contains converted numbers to scientific notation which is unusable. I want them to be save as text. Any trick to do that?
28160010390002003505456159
12160010390002003505456156
39160010390002003505456155
39160010390002003505456155
Append a TAB char (ASCII 9) at the end of a number.
In order to have those long (>15 digit) numbers in Excel, they are already formatted as text. I suspect that the .csv file also shows them as long numbers (if you open the csv file with Notepad), but that when you open the csv file in Excel, you see them as truncated and converted to scientific notation.
If that is the case, what you need to do is IMPORT the csv file. When you do that, the text-to-columns wizard will open, and allow you to format that column as text. The location of the Import is different in different versions. In Excel 2007, it is on the Data ribbon, Get External Data / From Text.
put the number as a function like below:
="123456789123456789"
If, as the original question seems to imply, you are actually:
already working with data in Excel, and
want to save to a CSV format without losing digits in an extra long number,
Then, before doing a 'Save As' to your CSV format, try formatting the column with a custom format, and in the box for the pattern just type #. This will force Excel to see it as a number, however many digits long, without trying to do something else with it like 4.52364E+14 when you actually save it to CSV.
At least, that is how it works for me in Excel 365 at this point in time.
If you are trying to get data into Excel from a CSV, then the answer about using the data import wizard is probably the safest bet instead.
This is an old question, but since at the moment it's still the top result on a google search for the topic, I think the thread should be kept current. Hussein mahyoub provided the only real answer to the question, yet has not gotten the up-votes.
The answer which tells us to add a tab character after your number gets you an string of text with a tab after it inside excel. It looks visually correct, but, it's not correct inside the spreadsheet. If the intent is to use the data in excel as excel data and use formula etc, it could cause problems. Interestingly if you put the tab before the text, it shows up in the data after the text.
The answer which tells us inserting a ' before the text gets a ' in the excel file. It's visually an incorrect representation of the data.
The answer which boasts the virtue of openoffice is simply an evil troll which does not even attempt to answer the question.
The answer that explains how to import a CSV that has not been properly formatted is good information, but, off topic.
The direct answer to the question is
converted to text,largest number
="123456789012",12345678901
Convert the numeric to text using text function.
Text(number,"0")
using openoffice you can save in csv format without problems.
Don't use Export to csv feature in Excel.
You can easy format that column to number in Excel, then use "Save as" it with csv and "yes" to confirm that you want to keep the format in csv.
That is work for me
Click on the column that has scientific exponent number and go to Format cells and then Numbers (decimal point as 0), save it as MSDOS CSV. Worked for me.

CSV for Excel, Including Both Leading Zeros and Commas

I want to generate a CSV file for user to use Excel to open it.
If I want to escape the comma in values, I can write it as "640,480".
If I want to keep the leading zeros, I can use ="001234".
But if I want to keep both comma and leading zeros in the value, writing as ="001,002" will be splitted as two columns. It seems no solution to express the correct data.
Is there any way to express 001, 002 in CSV for Excel?
Kent Fredric's answer contains the solution:
"=""001,002"""
(I'm bothering to post this as a separate answer because it's not clear from Kent's answer that it is a valid Excel solution.)
Put a prefix String on your data:
"N001,002","N002,003"
( As long as that prefix is not an E )
That notation ( In OpenOffice at least) above parses as a total of 2 columns with the N001,002 bytes correctly stored.
CSV Specification says that , is permitted inside quote strings.
Also, A warning from experience: make sure you do this with phone numbers too. Excel will otherwise interpret phone numbers as a floating point number and save them in scientific notation :/ , and 1.800E10 is not a really good phone number.
In OpenOffice, this RawCSV chunk also decodes as expected:
"=""001,002""","=""002,004"""
ie:
$rawdata = '001,002';
$equation = "=\"$rawdata\"";
$escaped = str_replace('"','""',$equation);
$csv_chunk = "\"$escaped\"" ;
Do
"""001,002"""
I found this out by typing "001,002" and then doing save-as CSV in Excel. If this isn't exactly what you want (you don't want quotes), this might be a good way for you to find what you want.
Another option might be use tab-delimited text, if this is an option for you.
A reader of my blog found a solution, ="001" & CHAR(44) & "002", it seems workable on my machine!
Pretty old thread but why don't you just add whitespace after your value. It will be then treated as string and no leading zeros will be stripped.
"001,002"." "
Since no-one mentioned it already, figured it was worth mentioning it in this old post.
If you add a horizontal tab character \t before the number, then MS Excel will also show the leading zero's. And the tab character doesn't show in the excel sheet. Even if it's surrounded by double-quotes. (F.e. \"\t001,002\")
It also looks nicer in Notepad++, compared to putting a \0 aka NULL before such number.
Looking more at the Excel spreadsheet it looks what you want can't be done using CSV.
This site http://office.microsoft.com/en-us/excel/HP052002731033.aspx says "If cells display formulas instead of formula values, the formulas are converted as text. All formatting, graphics, objects, and other worksheet contents are lost. The euro symbol will be converted to a question mark."
However, you can change how you load it to get the result you want. See this web page:
Microsoft import a text file.
The key thing is to choose Import External Data-Import Data-Text Files, go Next, Next, and then tick "Text" under column data format. This will prevent it being interpreted as a number, and losing formatting.
I was fiddling around with CSV to Excel (i use PHP to create the CSV, but i guess this solution works for any language. When you spot that a leading characters (such as + , - or 0 are disappearing, create the CSV with chr(13) as a prefix. This is a non printable character and it works wonders for my Excel Office 2010 version. I tried other non printable characters, but with no luck.
so i use Chirp Internet solution but tweaked with my prefix:
if (preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) {
$str = chr(13)."$str";
}
If you are using "Content-Disposition" and exporting from asp to excel using HTML tags,then you have to add "style='mso-number-format:\#;'" to that tag and making it to accept only Text values ,thereby leading zeroes omission will be avoided,If Forward slash"\" is accepted use double forward slash "\"
All the suggested answers don't seem to work for me right now ("=""blahblah""" and others) in all current Excel versions or Numbers app on OS X.
The only solution I found to be working by fiddling around is to add an escaped null character at the beginning of the string (which is \0 in PHP or C based languages). Everything ends up treated as is without being calculated or processed by the software when opening the calc sheet.
echo "\0" . $data;
Excel uses a default formatting for CSV columns depending on the content. So if you have 001 in a csv, excel will automatically turn it to 1.
The only way to keep the leading zeros in excel from a csv file is by changing the extension of the csv file to .txt, then just open excel, click on open, select the txt file, and you'll see the Text Import Wizard. Select your csv format (separated by commas), then just make sure you select "Text" as the format.
And that's it, now you can export that previous csv data to any other while keeping the leading zeros.
This is straightforward using Excel's Power Query functionality that allows you to perform step-by-step transformations.
Original File:
Add a Custom Column:

Resources