Created
July 9, 2022 18:55
-
-
Save alexlenail/250b945ee749a41d06a5fc4bff5ef012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
import numpy as np | |
def read_h5_to_dict(h5_path): | |
out_dict = {} | |
def add_h5_node_to_dict(name, node, out_dict=out_dict): | |
fullname = node.name | |
if isinstance(node, h5py.Dataset): | |
out_dict[fullname] = np.array(node) | |
with h5py.File(h5_path) as h5f: | |
h5f.visititems(add_h5_node_to_dict) # https://docs.h5py.org/en/latest/high/group.html#h5py.Group.visititems | |
return out_dict | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment