-1

I am trying to read a binary Excel file, but when I do, it turns all of the integer values into floats, adding ".0" at the end of each one.

I've tried moving everything to a list and just printing everything out before adding it to the list.

df = []
with open_xlsb('binaryexcelfile.xlsb') as wb:
    with wb.get_sheet(1) as sheet:
        for row in sheet.rows():
            df.append([item.v for item in row])

It reads 20003220514530.0, 20003220514540.0 instead of 20003220514530, 20003220514540. I can't just cast everything to an integer because not all the data is numeric, there are strings in it as well

Raj Patel
  • 11
  • 1
  • 9

1 Answers1

0

You can use function int():

df = []
with open_xlsb('binaryexcelfile.xlsb') as wb:
    with wb.get_sheet(1) as sheet:
        for row in sheet.rows():
            df.append([int(item.v) for item in row])
dallonsi
  • 1,299
  • 1
  • 8
  • 29