本文将为您描述python3_h2py_hdf5_遍历_查看文件结构,教程操作步骤:python3_h2py_hdf5_遍历_查看文件结构
转载注明来源: 本文链接 来自osnosn的博客,写于 2020-03-26.
pandas 的 hdf5 支持函数,好像没办法把 HDF5 文件的结构列出来。
只好使用 h5py,把HDF5文件的结构打印出来。输出的是文本信息
python 3.6, 以下都是用 pip3 install 安装的
h5py 2.10.0 (h5py的文档)
numpy 1.18.2
pandas 1.0.3 (hdf5 的支持, 需要安装 tables)
tables 3.6.1 (PyTables' documentation)
方法1:
#!/usr/bin/python3
# -- coding:utf8 --
fname='myfilename.hdf5'
import h5py
def prt(name):
print(name)
f = h5py.File(fname,'r')
f.visit(prt)
f.close()
方法2:
#!/usr/bin/python3
# -- coding:utf8 --
fname='myfilename.hdf5'
import h5py
import numpy as np
def h5list(f,tab):
print(tab,'Group:',f.name,'len:%d'%len(f))<