I want to add new method in Sheet Object (xlrd package), here is the code (in file Sheet.py):
from xlrd.sheet import Sheet
class Sheet(Sheet):
def dict_reader(self, fieldnames):
list_dict = []
for i, _ in enumerate(range(self.nrows)):
temp_dict = {}
for j, _ in enumerate(range(self.ncols)):
temp_dict.update(fieldnames[j], self.cell_value(i, j))
list_dict.append(temp_dict)
return list_dict
The problem is that when I call the method, It gives me AttributeError: 'Sheet' object has no attribute 'dict_reader'.
In the file I want to use it (file.py) the code is something like that :
import xlrd
from ..sheet import Sheet
workbook = xlrd.open_workbook(filename)
worksheet = workbook.sheet_by_index(0)
reader = worksheet.dict_reader(columns)
In the init.py file:
from . import Models_directory
My directory structure is something like that (yes, It is Odoo module directory architecture):
Main_directory
Sheet.py
Models_directory
file.py
__init__.py