from pyexcel_ods import get_data class ChapterTitle(dict): def __init__(self, filename): data = get_data(filename) header = data['Tabelle1'][0] headerindex = { 'c': header.index('Chapter'), 't': header.index('Original title'), 't_': header.index('Original_title'), } for row in data['Tabelle1'][1:]: try: i = int(row[headerindex['c']]) except ValueError: print('not matching', row) continue self[i] = { 't': row[headerindex['t']], 't_': row[headerindex['t_']] } def __call__(self, k): return self.__getitem__(k)