I need to read some huge database from HDF5 files and organize it in a nice way to make it easy to read and use.
I saw this post Python List as variable name and I'm trying to make a dictionary of dictionaries.
Basically I have a list of data sets and variables that I need to read form the HDF5 files. As an example I created this two lists:
dataset = [0,1,2,3]
var = ['a','b','c']
Now, there is legacy "home brewed" read_hdf5(dataset,var) function that reads the data from the HDF5 files and returns the appropriate array.
I can easily read from a specific dataset (say 0) at a time creating a dictionary like this:
data = {}
for type in var:
data[type] = read_hdf5(0,type)
Which gives me a nice dictionary if all the data for each variable in dataset 0.
Now I wan to be able to implement a dictionary of dictionaries so I can be able to access the data like this:
data[dataset][var]
That returns the array of data for the given set and variable
I tried the following but the only thing that the loop is doing is overwriting the last variable read:
for set in dataset:
for type in var:
data[set] = {'set':set, str(type): read_hdf5(set,type)}
Any ideas? Thank you!!!