Hi everyone I have such a data structure from CSV file. I would like to create a dictionary divided by place that contained the various dates referring to that day.
DATA | LUOGO | CAP | KEY
05/05/12 LUOGO1 05254 545122
05/05/12 LUOGO2 05554 545745
05/05/12 LUOGO3 05444 555544
05/05/12 LUOGO4 05774 777888
05/05/12 LUOGO5 05854 542225
06/05/12 LUOGO1 05554 585547
06/05/12 LUOGO2 07854 545888
06/05/12 LUOGO3 04544 585858
06/05/12 LUOGO4 05778 789585
06/05/12 LUOGO5 05785 525477
I'd get something like that with a for loop, I've been banging my head on it for days but I can't find a solution that I guess is trivial
luoghi = { 'LUOGO1':
{'05/05/12': {'data': '05/05/12', 'LUOGO': 'LUOGO1', 'CAP': '05254', 'KEY': '545122'},
'06/05/12': {'data': '06/05/12', 'LUOGO': 'LUOGO1', 'CAP': '05554', 'KEY': '585547'}},
'LUOGO2': {'05/05/12': {'data': '05/05/12', 'LUOGO': 'LUOGO2', 'CAP': '05554', 'KEY': '545745'},
'06/05/12': {'data': '06/05/12', 'LUOGO': 'LUOGO2', 'CAP': '07854', 'KEY': '545888'}}
}
print(luoghi['LUOGO1']['05/05/12'])
Result:
{'data': '05/05/12', 'LUOGO': 'LUOGO1', 'CAP': '05254', 'KEY': '545122'}
Can anyone tell me how with a FOR loop I can get it?
Thank you very much