Start a new topic

Import from excel, number is changed by DBvisualizer

[This topic is migrated from our old forums. The original author name has been removed]

I am trying to import data from excel sheet into postgres table one of the column contains numbers for example 2,382 (comma is a decimal separator here) , but when importing the number shown by DBvisualizer is 2.3820000000000001. This happens for all the numbers in the column. And excel column truly contains only 2.382 imput file excel .xlsx database postge , format of the column in table is text DBvisualizer version 9.2.9

[This reply is migrated from our old forums.]

Re: Import from excel, number is changed by DBvisualizer
Hi, I'm afraid this is the way excel stores it values. I.e manually entering 2.382 in excel will mean excel will store this number as a floating point number. When the floating point is stored it is rounded. Actually you can test this by your self by unzipping the xlsx file and have a look in the XML file representing the sheet. (E.g. xl/worksheets/sheet1.xml) This file would contain the value 2.3820000000000001. In DbVisualizer you may affect the number of decimals used when importing data by altering the "Decimal Number Format" property. This setting can be found in Tools->Tool Properties in the section "Data Formats". By setting the "Decimal Number Format" property to "####.###" your number should be imported as "2.382". However we have no way of detecting the true number entered by the user in excel as excel does store the number the way they are. Storing the xlsx file as an xls file and import the xls file instead would preserve the 2.382. I agree that it is strange that an older Microsoft format would behave better in that sense. Information about this Microsoft oddity can be found by googling a little bit. Some examples https://support.microsoft.com/en-us/kb/78113 https://blogs.office.com/2008/04/10/understanding-floating-point-precision-aka-why-does-excel-give-me-seemingly-wrong-answers/ http://www.codeproject.com/Articles/20246/Microsoft-Office-XML-formats-Defective-by-design#2 Regards Ulf
[This reply is migrated from our old forums. The original author name has been removed]

Re: Import from excel, number is changed by DBvisualizer
Thank you using an older format of excel file solved the problem