0
我通常使用h5py
做HDF5東西在Python和我是否想創建,我想以後擴展數據集,或者我做HDF5擴展陣列:使用PyTables
f = h5py.File('foo.h5', 'w')
d = f.create_dataset('whatever', (5, 5), maxshape=(None, 5), dtype='i8', chunks=True)
...
d.resize((23, 5))
...
的maxshape(None, ...)
設置第一維到「無限」,所以它是可擴展的。
現在我有一個項目,我需要堅持使用PyTables,並希望逐步構建大型數組。有沒有辦法在PyTables中擴展arrays
?
這大致的想法:
import tables as tb
import numpy as np
filename = "foo.h5"
h5file = tb.File(filename, "a")
gbar = h5file.create_group(h5file.root, "bar", "Pressure")
h5file.create_array(gbar, 'left', np.array((1, 2, 3, 4)), "...")
# now extend the shape of (4,) and append more arrays iteratively???
h5file.close()