根据FAQ,您可以使用扩展数据集
dset.resize。例如,
import osimport h5pyimport numpy as nppath = '/tmp/out.h5'os.remove(path)with h5py.File(path, "a") as f: dset = f.create_dataset('voltage284', (10**5,), maxshape=(None,), dtype='i8', chunks=(10**4,)) dset[:] = np.random.random(dset.shape) print(dset.shape) # (100000,) for i in range(3): dset.resize(dset.shape[0]+10**4, axis=0)dset[-10**4:] = np.random.random(10**4) print(dset.shape) # (110000,) # (120000,) # (130000,)


