Home > Blockchain >  Cannot read .xlsx file with read_excel()
Cannot read .xlsx file with read_excel()

Time:02-01

I want to open the .xlsx file through read_excel().

However, an error message is printed even though the openpyxl and pandas packages are installed.

The pandas version is 0.24.2 and the openpyxl version is 3.0.10.

The error message is - ValueError: Unknown engine: openpyxl

import pandas as pd
import math

retail_df = pd.read_excel('./Online_Retail.xlsx',engine='openpyxl')
print(retail_df.head())

CodePudding user response:

In Pandas 0.24.2 the default engine is openpyxl and for that, you don't need to set it up manually during loading the excel file inside the read_excel() function.

So now your updated working code for reading excel files is :

import pandas as pd
import math

retail_df = pd.read_excel('./Online_Retail.xlsx')
print(retail_df.head())

Testing result from my side with this code. enter image description here

  • Related