有没有办法将二进制文件存储到HDF5?
我有一个numpy .npy
文件,并希望将其存储在我的HDF中。我使用numpy格式,因为该文件具有 dtype u22 和 h5py 不喜欢这样。
有没有办法将此二进制文件存储在HDF中,因此我可以使用字典格式(例如file ['eneral/numpy_binary']
访问它。如果需要,我可以尝试提供MWE。
MWE:
a = np.Array([[['there',1,2,3],['that',4,5,6]])。astype('s10')
是一个2x4阵列。
with h5py.File('dump.h5','w') as debug:
g=debug.create_group('general')
dset = debug.create_dataset('general/data', data=a.tolist())
结果:
我希望将此数据视为2x4表。有可能吗?
I have a numpy .npy
file and would like to store this in my HDF. I use the numpy format because the file has dtype U22 and H5py does not like that.
Is there a way to store this binary file inside the HDF so I can access it using the dictionary format like file['general/numpy_binary']
. I can try to provide an MWE if required.
MWE:
a = np.array([['here',1,2,3], ['that',4,5,6]]).astype('S10')
which is a 2x4 array.
with h5py.File('dump.h5','w') as debug:
g=debug.create_group('general')
dset = debug.create_dataset('general/data', data=a.tolist())
results in this:
I would like to see this data as a 2x4 table. Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所展示的似乎是工具中的错。观察:
请注意,形状为(2,4)。文件中都存在两个行。
What you're showing seems to be a fault in your tool. Observe:
Note that the shape is (2,4). Both rows are present in the file.