繁体   English   中英

Python 带表格的 hdf5 文件:如何读取标题包含空白字符的 hdf 数据

[英]Python hdf5 file with tables: How to read hdf data where the title includes blank characters

如何将 hdf5 表数据块读取为:

domains = h5.root.name with blank

这是不可能的,但也许有特殊迹象?

您问题中的代码看起来像 pytables(不是 h5py)。 但是,您可以使用这两个包读取名称中带有空格的对象。
以下是使用每个 package 访问表或数据集的方法。 示例假设“name with blank”是一个数据集。 该代码仍然可以获取组 object,但您无法从组中获取数组。

h5py 方法:

domains_ds = h5['name with blank'] # returns dataset object
domains_arr = h5['name with blank'][()] # returns numpy array object

pytables 方法:

domains_ds = h5.get_node('name with blank') # returns table or array object as appropriate 
domains_arr = h5.read('name with blank') # returns numpy array object 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM