xxxxxxxxxx
XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'Sr. No.,'
xxxxxxxxxx
pip install xlrd==1.2.0
xxxxxxxxxx
# Make sure pandas is upgraded and that openpyxl is installed then try again
pip install pandas --upgrade
pip install openpyxl
xxxxxxxxxx
import openpyxl
# Specify the path of the xlsx file
file_path = 'path_to_file.xlsx'
try:
# Load the workbook
workbook = openpyxl.load_workbook(file_path)
# Select the active sheet (you can change this as per your requirements)
sheet = workbook.active
# Access individual cells and their values
for row in sheet.iter_rows():
for cell in row:
print(cell.value)
except Exception as e:
print(f"An error occurred while reading the xlsx file: {e}")
xxxxxxxxxx
As noted in the release email, linked to from the release tweet and noted in large orange warning that appears on the front page of the documentation, and less orange, but still present, in the readme on the repository and the release on pypi:
xlrd has explicitly removed support for anything other than xls files.
In your case, the solution is to:
make sure you are on a recent version of Pandas, at least 1.0.1, and preferably the latest release. 1.2 will make his even clearer.
install openpyxl: https://openpyxl.readthedocs.io/en/stable/
change your Pandas code to be:
df1 = pd.read_excel(
os.path.join(APP_PATH, "Data", "aug_latest.xlsm"),
engine='openpyxl',
)