Question

I am using Python to store data in an HDF5 database.

Every data set has a list of attributes associated with it.

I would like to retrieve all data sets that have a given attribute value.

For example, one attribute is temperature which could have a value of 20.0. I would like to call up all data sets with a temperature of 20.0.

Is there a quick way to do this?

Was it helpful?

Solution

Something like this?

[fh[i] for i in fh if fh[i].attrs['temperature']==20]]

Where fh is the hdf file handle.

This will return a list with all such datasets. If you only want their names, use:

[i for i in fh if fh[i].attrs['temperature']==20]]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top