(Nov-23-2018, 02:22 PM)ODIS Wrote: Hello amar,
you can do it like this:
lines = [ {'name':'ename','data':'str','len':'2','add':'bgl','out':'y','zip':'3567','add/blr':'Y'}, {'name':'another_name','data':'str','len':'2','add':'bgl','out':'y','zip':'3567','add/blr':'Y'} ] result = {} for line in lines: # extract the name from the line name = line["name"] # delete the name from the line del (line["name"]) # make the record in result result[name] = line print(result)
Hi,
DO i need to convert dict to list again like below, coz there are many rows .. coz im reading csv to df and doing json.loads to get dict
lines = [
{'name':'ename','data':'str','len':'2','add':'bgl','out':'y','zip':'3567','add/blr':'Y'},
{'name':'another_name','data':'str','len':'2','add':'bgl','out':'y','zip':'3567','add/blr':'Y'}
]