R
Roberto A. F. De Almeida
Hi,
Suppose I have a dictionary containg nested dictionaries. Something
like this:
{'casts': {'experimenter': None,
'location': {'latitude': None,
'longitude': None},
'time': None,
'xbt': {'depth': None,
'temperature': None}},
'catalog_number': None,
'z': {'array': {'z': None},
'maps': {'lat': None,
'lon': None}}}
I want to assign to the values in the dictionary the hierarchy of keys
to it. For example:
Of course I would like to do this automatically, independent of the
structure of the dictionary. Is there an easy way to do it?
Thanks,
Roberto
Suppose I have a dictionary containg nested dictionaries. Something
like this:
{'casts': {'experimenter': None,
'location': {'latitude': None,
'longitude': None},
'time': None,
'xbt': {'depth': None,
'temperature': None}},
'catalog_number': None,
'z': {'array': {'z': None},
'maps': {'lat': None,
'lon': None}}}
I want to assign to the values in the dictionary the hierarchy of keys
to it. For example:
dataset['casts']['experimenter'] = 'casts.experimenter'
dataset['z']['array']['z'] = 'z.array.z'
Of course I would like to do this automatically, independent of the
structure of the dictionary. Is there an easy way to do it?
Thanks,
Roberto