excel_info DEF (Self, Paths, types, sheetname = None): '' 'reads each line of information each column : param paths file path : param types primary: take the first sheet Content field: table of contents taking field ' '' = load_workbook Excel (Paths) IF types == 'Primary': NUM = excel.get_sheet_names () # Get Sheet: Table excel.get_sheet_by_name = (NUM [0]) IF types == 'Field': IF sheetname == None: Print ( 'empty sheet') return False table Excel = [sheetname] obtained by the table name # : # Get the number of rows and columns acquires rows rows = table.max_row # cols = table.max_column # Get the number of columns # obtaining cell value: S = [] J = 2 for X in Range (rows -. 1): F = {} for I in Range (. 1, cols. 1 +): value = table.cell (row = j, column = i) .value # starting from the second row, obtaining values for each column # IF value == None: # value = '' dict_value = table.cell (row =. 1, column = i) .value # taking the first row of each column to the key value of F [dict_value] = value s.append (F) J + =. 1
NOTE: primary read the first sheet, form sheet according to the relevant reading associated with the first sheet