You can use h5py
python package to examine .h5
file structure. The following script prints out the structure of any .h5
file.
import h5py
def print_h5_structure(f, level=0):
""" prints structure of hdf5 file """
for key in f.keys():
if isinstance(f[key], h5py._hl.dataset.Dataset):
print(f"{' '*level} DATASET: {f[key].name}")
elif isinstance(f[key], h5py._hl.group.Group):
print(f"{' '*level} GROUP: {key, f[key].name}")
level += 1
print_h5_structure(f[key], level)
level -= 1
if f[key].parent.name == "/":
print("\n"*2)
file_path = "path/to/file.h5"
f = h5py.File(file_path, 'r')
print_h5_structure(f)
Sample .h5
file output:
GROUP: ('BEAM0000', '/BEAM0000')
DATASET: /BEAM0000/all_samples_sum
GROUP: ('ancillary', '/BEAM0000/ancillary')
DATASET: /BEAM0000/ancillary/master_time_epoch
DATASET: /BEAM0000/ancillary/mean_samples
DATASET: /BEAM0000/ancillary/smoothing_width
DATASET: /BEAM0000/beam
DATASET: /BEAM0000/channel
DATASET: /BEAM0000/delta_time
GROUP: ('geolocation', '/BEAM0000/geolocation')
...
...