I have dictionary,
d = [{
'id': 1
'a' : [11,12],
'b' : [25,17],
'c' : [13,18]
}]
Here I want to write in csv with column headers as keys (id,a,b,c) and values as rows. Here I want to write first row has values (1,11,25,13) with keys (id,a,b,c) and second row will have values (1,12,17,18) with the same keys having id same for both rows. Meaning if my value has more than two values it needs to be written in csv in next row with same columns headers and same id.
I was trying something like this
CSV ="\n".join([k+','+",".join(v) for k,v in dict_data[0].items()])
print CSV
But again, the columns are coming as row, csv file id,1,(no value, i need 1 here) ---- Here id will not appear a,11,12 b,25,17 and they are coming as rows, i want id, a b as columns
idkey always be anint, or can it also be alistobject? How regular is your data?.csv, or use a library such aspandasthat have methods that write.csvfile, corresponding to your datas (you will need to format your data according topandasof course).csvlibrary?