python - Updating h5py Datasets -
does 1 have idea updating hdf5 datasets h5py? assuming create dataset like:
import h5py import numpy f = h5py.file('myfile.hdf5') dset = f.create_dataset('mydataset', data=numpy.ones((2,2),"=i4")) new_dset_value=numpy.zeros((3,3),"=i4")
is possible extend dset 3x3 numpy array?
you need create dataset "extendable" property. it's not possible change after initial creation of dataset. this, you need use "maxshape" keyword. value of none
in maxshape
tuple means that dimension can of unlimited size. so, if f
hdf5 file:
dset = f.create_dataset('mydataset', (2,2), maxshape=(none,3))
creates dataset of size (2,2), may extended indefinitely along first dimension , 3 along second. now, can extend dataset resize
:
dset.resize((3,3)) dset[:,:] = np.zeros((3,3),"=i4")
the first dimension can increased as like:
dset.resize((10,3))