willtrnr / pyxlsb

Excel 2007+ Binary Workbook (xlsb) reader for Python
GNU Lesser General Public License v3.0
90 stars 21 forks source link

Some negative floats are read incorrectly #2

Closed ebmoll closed 6 years ago

ebmoll commented 6 years ago

Hi,

first, thanks a lot for the library! I found a (quite serious) bug: If I try to load a file containing the numbers "-20222.7" or "-11459.53", they are incorrectly read as "10717195.54" and "10725958.71" respectively. I made a short demo excel:

bug.zip Content of "bug.xlsb" is:

TEXT
-20'222.80
-20'222.70
-4'718.63
-11'459.53
-4'044.54

If I execute the following code:

import pyxlsb
wb = pyxlsb.open_workbook("bug.xlsb")
sheet = wb.get_sheet(1)
rows = sheet.rows()
for row in rows: print (row)

Output:

python bug.py
[Cell(r=0, c=0, v='TEXT')]
[Cell(r=1, c=0, v=-20222.8)]
[Cell(r=2, c=0, v=10717195.54)]
[Cell(r=3, c=0, v=-4718.63)]
[Cell(r=4, c=0, v=10725958.71)]
[Cell(r=5, c=0, v=-4044.54)]

I'm using 64-bit python 3 on Windows 10 ("Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32")

I have looked quickly in the source code, but I have no idea what causes it. It seems to bee very well reproducible, however.

Greets, Samuel

willtrnr commented 6 years ago

Thanks a lot for this detailed report, this is indeed quite serious, BIFF12 encodes numbers very weirdly so I'll try to take a look ASAP.

willtrnr commented 6 years ago

It should be fixed in 1.0.2

ebmoll commented 6 years ago

Wow, that was fast! Thanks a lot for the fix! -------- Original message --------From: William Turner notifications@github.com Date: 11/22/17 08:07 (GMT+01:00) To: wwwiiilll/pyxlsb pyxlsb@noreply.github.com Cc: ebmoll samimoll@googlemail.com, Author author@noreply.github.com Subject: Re: [wwwiiilll/pyxlsb] Some negative floats are read incorrectly (#2) It should be fixed in 1.0.2

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/wwwiiilll/pyxlsb","title":"wwwiiilll/pyxlsb","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/wwwiiilll/pyxlsb"}},"updates":{"snippets":[{"icon":"PERSON","message":"@wwwiiilll in #2: It should be fixed in 1.0.2"}],"action":{"name":"View Issue","url":"https://github.com/wwwiiilll/pyxlsb/issues/2#issuecomment-346261962"}}}