44

I have a CSV file with the following values:

3271.96;274;272;1;1;0;1;0.071690;0;0;0;0;0;0;1.753130;1.75;0;1.75;

But when I open the file with Excel I get this:

3271.96 274 272 1   1   0   1   0.071690    0   0   0   0   0   0   1.753.130   1.75    0   1.75

Why is "1.753130" converted into "1.753.130"? (1.753130 is a decimal number) how can I "force" Excel to understand that these are decimal numbers?

I create the CSV file with a web application, so is difficult just modify my Excel configuration because many people visit my website and download the CSV file to their machines.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Naty Bizz
  • 2,262
  • 6
  • 33
  • 52
  • 1
    Are you using a dutch version of windows? You can confirm that by looking in Regional Settings in Control Panel. If yes, then check if "." is set as a thousands separator... – Siddharth Rout Jul 10 '12 at 20:19
  • Excel & CSV is a never ending pain, especially when you're on the producing end with 0 control on what exact version and language the receivers are using, maybe this SO article gives you some inspiration http://stackoverflow.com/questions/137359/excel-csv-number-cell-format. Btw, we switched to generating XLS mainly for that reason – fvu Jul 10 '12 at 20:26
  • have you tried my suggestion below? – Alex Gordon Jul 10 '12 at 23:17
  • @Артём Царионов yes I tried your suggestion, but I already found the solution: my value "1.753130" is a decimal with a dot, excel "understands" the decimal numbers with commas, so I changed the dot and now works fine – Naty Bizz Jul 11 '12 at 02:00
  • @NatyBizz you can change your regional settings: http://windows.microsoft.com/en-us/windows7/Change-the-country-or-region-setting – Alex Gordon Jul 11 '12 at 17:08
  • @l--''''''---------'''''''''''' No need to change the regional settings, check the answer by smoothumut below – nkatsar Feb 21 '18 at 17:08

8 Answers8

42

For users seeking to this question with newer Excel versions like Excel 365... As written at Professor Excel you could activate/restore "From Text (Legacy)" in the settings.

My prefered solution

File - Options - Data

Excel settings - From Text(Legacy)


Then you will be able to get the old import wizard... legacy but in my opinion more intuitiv.

Link to legacy import wizard


Other possibilities

At that linked Professor Excel website there are also shown other possibilities. With Excels new import dialog, if you have several columns with numbers all in a different locale to your computers locale settings, then it will be much more effort to do the import. With the old wizard you are set within a minute. With the new import dialog I haven't found yet a method to be as fast as with the legacy import method.

MarkusEgle
  • 2,795
  • 4
  • 41
  • 61
17

As of now (Sep, 2020), I managed to do this in a slightly different way. I'm using Excel from a Office 365 subscription.

With your Excel sheet open, go to:

  • Data (tab) > From Text/CSV (Get & Transform Data section)

Select your file (.txt or .csv), then you'll have 3 options:

  • File Origin: probably you won't have to change this
  • Delimiter: choose whatever your delimiter is (probably comma)
  • Data Type Detection: change this to "Do not detect data types"
Dharman
  • 30,962
  • 25
  • 85
  • 135
rnahumaf
  • 391
  • 1
  • 3
  • 6
  • great thanks. After importing, I can change the respective columns with search&replace as I would do prior to importing with notepad – Florian Apr 14 '21 at 07:59
  • Link for a more detailed instruction on how to do this in the case of changing file-origin: https://community.powerbi.com/t5/Desktop/Thousand-Separator-and-Decimal-Separator/m-p/194928 – Oliver May 03 '21 at 09:25
  • It works for me. I know because actually, the excel when they import our csv, they write some querry (the querry can you check in transform data menu). in there, you can see that they decide the data type of the csv. Thanks man! – Adhim Bagas May 17 '23 at 22:15
15

here is the answer I used:

  • go to Data tab on excel sheet.

  • click on from Text button.

  • then select text or csv file.

  • then the import wizard will come out. select comma separated or space separated option.

  • then select delimiter. (this is better if you don't want it to have problem while importing decimals)

  • then in the next window there will be Advanced option for General column type. Click the advanced button and choose how to separate decimals and thousands.

Change the decimal separator to a "." and remove the thousand separator with a space.

sandstrom
  • 14,554
  • 7
  • 65
  • 62
smoothumut
  • 3,423
  • 1
  • 25
  • 35
  • 2
    This is actually the correct answer, the OP is NOT asking how to change the DELIMITER to a semicolon (;) but how to import numbers using different DECIMAL and THOUSANDS separators than his default regional settings. – nkatsar Feb 21 '18 at 17:06
  • 1
    This does not work if you have a string column that contains new lines – Dan Oct 09 '18 at 06:38
  • 12
    this is not true anymore for newer versions of Excel. – Steffen Roller Nov 12 '19 at 21:02
9
  1. rename the csv to .txt
  2. open excel
  3. go to file-->open and point to your txt file
  4. go through the steps of importing it
  5. make sure to use ; as the delimitter
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
  • Why would you need to rename the file? – Jesse Jul 11 '12 at 00:23
  • 1
    the reason is because if you double click a csv file, it will assume which ever delimitter is set in your regional settings, whereas opening a txt using excel, it will ask what delimitter you want to use – Alex Gordon Jul 11 '12 at 03:21
  • 8
    Just go to the Data ribbon and choose "from text" in the get external data group. There's no need to rename the file. – Jesse Jul 11 '12 at 06:11
  • 5
    Why is this the accepted answer? Where is the decimalseparator converted to the user decimalseparator – Dan Oct 09 '18 at 06:36
  • Agree with Dan, this answer seems outdated, my Office 365 Excel version only has encoding and cell separator options in the text/csv import dialog. – Maximilian Schier May 12 '19 at 09:01
  • Consider using this answer https://stackoverflow.com/a/56786038/1828296 as an accepted solution. At least for me it worked like a charm. – lospejos Jun 26 '23 at 14:58
4

I had the same problem but solely this solution didn't work out for me.

Before that I had to go to Office icon -> Excel Options -> Advanced and set the thousand delimitter from "." to "" (nothing).

Teo Inke
  • 5,928
  • 4
  • 38
  • 37
  • 2
    And enter a space is required, because setting this to empty resulted in being reset to "." after restarting excel – Erik Oppedijk Mar 10 '17 at 12:39
  • 1
    Very useful to know that one can change the decimal and thousand separators Excel is using. Also for those who want to save their Excel files to CSV with dot as decimal separator! Personally I don't recommend using space as the thousand separator: it can become a problem for somebody else when the data are exported to PDF. Anyone who wants to then copy those data back into Excel will have a hard time parsing those numbers. I don't understand why in 2003 the General Conference on Weights and Measures recommended the space. I'd recommend apostrophe or otherwise underscore as thousand separator. – Dobedani Apr 18 '18 at 10:49
3

There is a more straight forward method to import data from text/csv into Excel (2017):

  • Open a blank book in Excel and click in import data from text/csv.
  • Select the file.
  • The assistant will show a preview of the data, but if you are importing from a csv with decimal / scientific numbers all will be recognized as text.
  • Before importing, click on edit, you will see an Excel spreadsheet with a preview of your data.
  • If you click on the advanced editor button, a new window with the query Excel does will appear.

You will see something like:

let
    Origin = Csv.Document(File.Contents("C:\Users\JoseEnriqueP\Downloads\evaluation_output.txt"),[Delimiter=",", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Updated type" = Table.TransformColumnTypes(Origin,{{"Column1", Int64.Type}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}})
in
    #"Updated type"

Then, you can write down directly the types for each column: - Text: type text - Integers: Int64.Type - Decimals: Double.Type

The import code would be as follows:

let
    Origin = Csv.Document(File.Contents("C:\Users\JoseEnriqueP\Downloads\evaluation_output.txt"),[Delimiter=",", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Updated type" = Table.TransformColumnTypes(Origin,{{"Column1", Int64.Type}, {"Column2", Int64.Type}, {"Column3", Int64.Type}, {"Column4", type text}, {"Column5", Double.Type}, {"Column6", Double.Type}})
in
    #"Updated type"

By doing this, you will get directly your data into Excel.

1

If you have a newer version of Excel(e.g. Office 365) and you don't need to correct the file's encoding, here is what worked for me:

  1. open the .csv file by double clicking it in your file explorer
  2. select the column(s) containing decimal numbers
  3. use Find and Replace to change all dots (.) to a comma (,) sign

This assumes that no other data transformations are needed(which would likely require going through the import wizard), and that the file's encoding is correctly recognized by Excel.

If encoding is also an issue, do the following before the steps above:

  1. edit the file in Notepad++
  2. open the Encoding menu tab
  3. choose a desired value to convert the file's encoding

Some of the other answers work also, but for sheer simplicity, you can't beat the Find and Replace method. No matter what you do, here is the most important step: Live long and prosper!

0

Something that worked for me in 2012 version of Excel is that when you import data, you have the option to open a 'Transform Data' box. In this box on the right side panel, you can see a list of 'Applied Steps'. These are the steps which excel applies on the source file. You can remove the steps from this list which are causing problems. I had a problem with excel ignoring the decimal point while importing from my text file but this resolved the issue.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 14 '22 at 11:51