xlsxwriter - Writing a Dictionary with a list of values to an Excel file -


using python3 have dictionary on 100 keys. each key's value list. want write each key of dictionary excel document each term having own cell, on same row.

row = 0 col = 0  mydictionary = {     'car seat':['$10', '12', 'it1'],     'piano':['$12', '2', 'it1'],     'picture frame':['$2', '14', 'it1'],     'shoes':['$20', '13', 'it1'],     }  key in mydictionary.keys()::     result = [str(key), mydictionary[key]]     worksheet.write_row(row, col, result)     row += 1 

expectedoutput.xlsx (header not included):

key           / listvalue1 / listvalue2 / listvalue3 car seat      / $10        / 12         / it1 piano         / $12        / 2          / it1 picture frame / $2         / 14         / it1 shoes         / $20        / 13         / it1 

the problem im having can excel use 2 columns: key / value

instead of 4 columns need: key / value1 / value2 / value3

since have on 100 entries in dictionary, goal write each key excel can sort easily.

what print comma separated list csv file.

"key","listvalue1","listvalue2","listvalue3" "car seat","$10", "12", "it1" "piano","$12", "2", "it1" "picture frame","$2", "14", "it1" "shoes","$20", "13", "it1" 

this can done in python , excel should able open it. can manipulate data in spreadsheet or can copy spreadsheet, or spreadsheet tab, if need elsewhere.


Comments