Skip to content Skip to sidebar Skip to footer

Getting Multiple Datasets From Group In Hdf5

I am comparing two different hdf5 files to make sure that they match. I want to create a list with all of the datasets in the group in the hdf5 file so that I can have a loop run t

Solution 1:

To get the datasets or groups that exist in an HDF5 group or file, just call list() on that group or file. Using your example, you'd have

datasets = list(ft['/PACKET_0'])

You can also just iterate over them directly, by doing:

for name, data in ft['/PACKET_0'].items():
    # do stuff for each dataset

If you want to compare two datasets for equality (i.e., they have the same data), the easiest way would be to do this:

(dataset1.value == dataset2.value).all()

This returns NumPy arrays from each dataset, compares those arrays element-by-element, and returns True if they match everywhere and False otherwise.

You can combine these two concepts to compare every dataset in two different files.

Post a Comment for "Getting Multiple Datasets From Group In Hdf5"