我无法使用h5py重新读取数据. “无法创建组" [英] I can't read data back in using h5py. "unable to create group"
本文介绍了我无法使用h5py重新读取数据. “无法创建组"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在快速入门页面上完成一个简单的示例
I'm trying to complete the trivial example on the quickstart page
http://www.h5py.org/docs/intro/quick.html
import h5py
f = h5py.File('myfile.hdf5','w')
dset = f.create_dataset("MyDataset", (100, 100), 'i')
dset[...] = 42
f.close()
ff = h5py.File('myfile.hdf5','r')
dset = ff.create_group("MyDataset")
输出是
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/h5py/_hl/group.py", line 28, in create_group
gid = h5g.create(self.id, name, lcpl=lcpl)
File "h5g.pyx", line 135, in h5py.h5g.create (h5py/h5g.c:2057)
ValueError: unable to create group (Symbol table: Unable to initialize object)
我要正确执行此操作吗?
Am I trying to do this correctly?
推荐答案
使用'a'
模式附加到文件,并且不要使用与数据集相同的名称来命名组:
Use 'a'
mode to append to the file, and do not name the group the same name as the dataset:
import h5py
with h5py.File('myfile.hdf5','w') as f:
dset = f.create_dataset("MyDataset", (100, 100), 'i')
dset[...] = 42
with h5py.File('myfile.hdf5','r+') as ff:
dset = ff.create_group("MyGroup")
这篇关于我无法使用h5py重新读取数据. “无法创建组"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文