python - I wanna make a dictionary has user_id's key & all excel data -


i wanna make dictionary has user_id's key & excel data . excel excel

in views.py wrote

def try_to_int(arg):     try:         return int(arg)     except:         return arg  def main():     book3 = xlrd.open_workbook('./data/excel1.xlsx')     sheet3 = book3.sheet_by_index(0)      data_dict = ordereddict()     tag_list = sheet3.row_values(0)[1:]     row_index in range(1, sheet3.nrows):         row = sheet3.row_values(row_index)[1:]         row = list(map(try_to_int, row))         data_dict[row_index] = ordereddict(zip(tag_list, row))      print(data_dict)  main() 

print(data_dict)

ordereddict([(1, ordereddict([('', ''), ('ton', ''), ('0014500ab9cd', '')])), (2, ordereddict([('', ''), ('tom', ''), ('0014500ab9cd', '')])), (3, ordereddict([('', ''), ('tom', 'a'), ('0014500ab9cd', '')]) 

it not ideal result. wanna make dictionary like

dicts = {     0014500ab9cd: {         new york_a-a_under500: ○,         new york_a-a_500-700: ○,           ・・・・         new york_a-e_under500: ○,           ・・・・         new york_c-b_upper700: ×,     },     0014500ab9cd: {        chicago_a-a_under500: ○,        chicago_a-a_500-700: ○,           ・・・・     }, } 

i not have name data.how can ideal dictionary?what should write it?

rows like

['', '16690', '0014500ab9cd', 'tom', '40', '', 'leader']['', '28818', '000000ywaub', 'blear', '23', 'others'] 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -