You can use the .copy()
method to recursively copy objects from f1.h5
to f2.h5
. You don't need to know the schema: use keys to access groups/datasets at the root level. If the source is a Group object, by default all objects within that group will be copied recursively.
import h5py
h5r=h5py.File("f1.h5", 'r')
with h5py.File("f2.h5", 'w') as h5w:
for obj in h5r.keys():
h5r.copy(obj, h5w )
h5r.close()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…