【发布时间】:2017-07-05 20:42:28
【问题描述】:
我通常使用h5py 在 Python 中完成 HDF5 的工作,如果我想创建一个以后想要扩展的数据集,或者,我会这样做:
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()
【问题讨论】:
标签: pytables