How to list all datasets in h5py file?

matchifang picture matchifang · Jul 3, 2017 · Viewed 17.4k times · Source

I have a h5py file storing numpy arrays, but I got Object doesn't exist error when trying to open it with the dataset name I remember, so is there a way I can list what datasets the file has?

   with h5py.File('result.h5','r') as hf:
        #How can I list all dataset I have saved in hf?

Answer

max9111 picture max9111 · Jul 6, 2017

You have to use the keys method. This will give you a List of unicode strings of your dataset and group names. For example:

Datasetnames=hf.keys()

Another gui based method would be to use HDFView. https://support.hdfgroup.org/products/java/release/download.html