1

Trying to read a xlsb file to create a DF in pandas.

import pandas as pd

a_data = pd.ExcelFile(
    r'C:\\Desktop\\a.xlsb')

df_data = pd.read_excel(a_data, 'Sheet1', engine='pyxlsb')
print(df.head())

When I run the script I keep getting this error.

OSError: File contains no valid workbook part

caddie
  • 169
  • 1
  • 3
  • 11

1 Answers1

2

You can use pyxlsb, all latest version of pandas support this. Use following code:

import pandas as pd
a_data = pd.ExcelFile(r'C:\\Desktop\\a.xlsb')
df = pd.read_excel('a_data', sheet_name='Sheet1', engine='pyxlsb')

You will have to install pyxlsbfirst using command: pip install pyxlsb

M_S_N
  • 2,764
  • 1
  • 17
  • 38