【发布时间】:2020-05-28 22:48:36
【问题描述】:
def storeFlagsFile(FLAGS_F, file_name, t0, text, ID):
if not FLAGS_F: # this flag doesnt work for mulitple users
f = h5py.File(file_name, "r+")
data_content = np.array([np.round(time.time() - t0, 3), text])
asciiList = np.array([str(n).encode("utf-8", "ignore") for n in data_content]).reshape(1, 2)
dt = h5py.string_dtype(encoding='utf-8')
dset = f[str(ID)].create_dataset('AcqFlags', data=asciiList, compression="gzip", chunks=True, maxshape=(None, 2), dtype=dt)
FLAGS_F = 1
else:
f = h5py.File(file_name, "r+")
data_content = np.array([np.round(time.time() - t0, 3), text])
asciiList = np.array([str(n).encode("utf-8", "ignore") for n in data_content]).reshape(1, 2)
f[str(ID)+'/AcqFlags'].resize((f[str(ID)+'/AcqFlags'].shape[0] + 1), axis = 0)
f[str(ID)+'/AcqFlags'][-1:] = asciiList
我想以 (None, 2) 格式保存这样的数据格式,因为我通过调用 storeFlagsFile 函数不断更新每行的数据行。
['4.412' 'a']
['5.412' 'b']
['6.412' 'c']
['8.226' 'd']
其中 t0 第一列和文本 = 数据的第二列,我将其作为每行的输入行提供给 storeFlagsFile(FLAGS_F, file_name, t0, text, ID)。 FLAGS_F 最初为 0,ID = "122"。
谁能指出我做错了什么?谢谢!
【问题讨论】: