caddie
caddie

Reputation: 169

Using Pandas with XLSB File

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

Upvotes: 1

Views: 2583

Answers (1)

M_S_N
M_S_N

Reputation: 2810

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

Upvotes: 2

Related Questions