DDF: Part 4: Error - xlrd.biffh.XLRDError | Selenium Python Forum
G
Gaurav Valera Posted on 17/02/2021

Hi,

Please guide me to resolve the error: xlrd.biffh.XLRDError: Excel xlsx file; not supported

temp.py file:

from testresources.dataReading import XLSReader


def getData():
    xls = XLSReader("C:\\Git_Data\\automationFrameworks\\DataDrivenFramework\\testresources\\DDF.xlsx")
    print(xls.readXLS.sheet_by_name("sheet1").cell_value(2,1))


getData()

Output:

Traceback (most recent call last):
  File "C:/Git_Data/automationFrameworks/DataDrivenFramework/temp.py", line 9, in <module>
    getData()
  File "C:/Git_Data/automationFrameworks/DataDrivenFramework/temp.py", line 5, in getData
    xls = XLSReader("C:\\Git_Data\\automationFrameworks\\DataDrivenFramework\\testresources\\DDF.xlsx")
  File "C:\Git_Data\automationFrameworks\DataDrivenFramework\testresources\dataReading.py", line 8, in __init__
    self.readXLS = xlrd.open_workbook(path)
  File "C:\Users\valergau\PycharmProjects\ShoppingDemo\venv\lib\site-packages\xlrd\__init__.py", line 170, in open_workbook
    raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
xlrd.biffh.XLRDError: Excel xlsx file; not supported

For your reference - dataReading.py:

import xlrd
import xlwt


class XLSReader:
    def __init__(self, path):
        self.path = path
        self.readXLS = xlrd.open_workbook(path)

 


0
09914040666 Replied on 18/02/2021

Hey, 

Kindly change the extension of your excel file from ".xlsx" to ".xls" and then try. 


G
Gaurav Valera Replied on 18/02/2021

Thanks its working with .xls format. 

Kindly let me know why error occurs with .xlsx format

Regards,

Gaurav

 


0
09914040666 Replied on 19/02/2021

Hey,

Thank you for the update and reason for error is from the xlrd package, ".xlsx" format has been removed explicitly for some reason. That is why that happens


G
Gaurav Valera Replied on 23/02/2021

Thanks. Please Close the ticket


Related Posts