Copy almost all files
Suppose that you want to copy all but some dataset from a file. In that case you can use
GooseHDF5.getdatasets()to get a list of all datasets.
GooseHDF5.copydatasets()to copy a bunch of datasets.
Consider the following example.
import h5py import numpy as np import GooseHDF5 as g5 with h5py.File("foo.h5", "w") as data: data["/a"] = np.arange(5) data["/b/c"] = np.arange(5) data["/d/e/f"] = np.arange(5) with h5py.File("foo.h5", "r") as data: paths = list(g5.getdatasets(data)) paths.remove("/d/e/f") with h5py.File("bar.h5", "w") as ret: g5.copy(data, ret, paths) ret["/d/e/f"] = data["/d/e/f"][...] * 2
The copy functions from h5py copy attributes as well.
By extension also
GooseHDF5.copydatasets() copies all attributes.
If you manipulate data yourself you will want to make sure that copy the relevant attributes.