| import h5py | |
| # File path | |
| filename = 'frac_pull_z_15044.h5' | |
| # Save data to dictionary | |
| data_dict = {} | |
| # Open and traverse the HDF5 file | |
| with h5py.File(filename, 'r') as f: | |
| def collect_datasets(name, obj): | |
| if isinstance(obj, h5py.Dataset): | |
| print(f"Loading dataset: {name}, shape: {obj.shape}, dtype: {obj.dtype}") | |
| data_dict[name] = obj[()] # Load entire dataset into memory | |
| f.visititems(collect_datasets) # walk through h5 and collect in data_dict | |