def index_row_header(sheet, logger, table_name): """ creating a dictionary for each row """ header = [sheet.cell(0, col_index).value for col_index in xrange(sheet.ncols)] new_header = modify_header(header) dict_list = get_each_data_fields(sheet, new_header, 1, sheet.nrows) target = [record(i) for i in dict_list] return (dict_list, target)
def sample_data(sheet,new_header, data_index, carrier_table_headers, caid_cast_table_headers): """ going throw each row and making a dictionary out of it creating table specific dictionaries """ carrierID_dict = {} caid_plate_dict = {} Sample_Name = [] needed = data_index[0] data_list = get_each_data_fields(sheet, new_header, needed[0], needed[1]) target = [record(r) for r in data_list] for l in target: if l.Sample_Name != '': Sample_Name.append(l.Sample_Name) carrierID_dict[l.Sample_Name] = [v for k, v in l.__dict__.iteritems() if k in carrier_table_headers] caid_plate_dict[l.Sample_Name] = [v for k, v in l.__dict__.iteritems() if k in caid_cast_table_headers] return(carrierID_dict, caid_plate_dict, Sample_Name)