一些数据需要以不同的步骤写入HDF5文件,下面是示例代码。我遇到的问题是,当新步骤(包括打开和写入)再次运行时,现有的h5组和数据集被清理
import h5py
import numpy as np
a=r"F:\HY1A1B\cd.h5"
#first open and write
b=h5py.File(a, 'w')
zeroPixelCounts = np.zeros((5,10))
QC_Attribute = b.create_group("QC Attributes")
QC_Attribute.create_dataset("Zero Pixel Counts",(5,10),data=zeroPixelCounts)
b.close()
#second open and write
b=h5py.File(a, 'w')
QC_Attributex = b.create_group("QC Attributes xxxx")
QC_Attributex.create_dataset("Zero Pixel Counts",(5,10),data=zeroPixelCounts)
b.close()
#problem:the existing data in first open and write processing were cleaned
我认为模式“w”将始终创建一个新的HDF5文件,因此第二次必须以读/写/创建模式打开(“a”,用于附加):
为我工作:
相关问题 更多 >
编程相关推荐