File size: 489 Bytes
f70850f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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