I've a hdf5 file in the below format. {...}
represent groups and some have subgroups.
download the file with the below link
https://drive.google.com/file/d/1f6a0XEPGE4aSEKODVbJ1Q9AUw24Bt9_2/view?usp=sharing
{'A': np.array(...),
'B':np.array(...),
'C':{
'A': np.array(...),
'B': {...},
'C': np.array(...),
'D': np.array(...)},
'D':{
'A': {...},
'B': {...},
'C': {...},
'D': {...}}
}
I'm trying with the below code to create a dictionary but it is not in the correct format. can someone help with this ?
import h5py
import numpy as np
driv
def read_hdf5_file(file):
for key,val in file.items():
if type(val) == h5py._hl.dataset.Dataset:
d[key] = np.array(val)
# print(key,np.array(val))
else:
d[key] = read_hdf5_file(val)
return d
if __name__=='__main__':
d = dict()
file = h5py.File("data.hdf5")
read_hdf5_file(file)