h5py - 如何使用 h5py 遍历 hdf5 文件

标签 h5py

如何使用 h5py 遍历 hdf5 文件的所有组和数据集?

我想使用 for 循环或类似的东西从公共(public)根目录检索文件的所有内容。

最佳答案

visit()visititems()是你的 friend 吗?参照。 http://docs.h5py.org/en/latest/high/group.html#Group.visit .请注意,h5py.File也是 h5py.Group .示例(未测试):

def visitor_func(name, node):
    if isinstance(node, h5py.Dataset):
         # node is a dataset
    else:
         # node is a group

with h5py.File('myfile.h5', 'r') as f:
    f.visititems(visitor_func)

关于h5py - 如何使用 h5py 遍历 hdf5 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31146036/

相关文章:

python - HDF5 添加 numpy 数组速度慢

python - 使用 python h5py 读取 .mat 文件中的所有变量

multithreading - 多个小的 h5 文件或一个巨大的文件之间最好的是什么?

python - h5py 使用指针的对称数组

python - h5py无法读取fast5文件

python - 如何使用 h5py 读取只有数据集(没有组)的 HDF5 文件?

python - 精细控制 h5py 缓冲

python - h5py 接受什么 numpy dtypes?

python - 输入和输出 numpy 数组到 h5py

python - h5py:如何在不将所有内容加载到内存的情况下索引多个大型 HDF5 文件