如何在Python中检查.h5文件 [英] How to inspect .h5 file in Python

查看:663
本文介绍了如何在Python中检查.h5文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看给定的.h5文件在Python中具有哪些变量,数据集等?

How do I see what variables, datasets, etc. a given .h5 file has in Python?

我可以通过运行此文件来读取文件

I can read the file by running this

import h5py
f = h5py.File(filename, 'r')

我现在如何查看我的.h5文件具有哪些变量?

How can I now see which variables my .h5 file have?

正在运行f.keys()会输出非信息

KeysView(<HDF5 file filename (mode r)>)

在Matlab中,我只是调用h5disp(filename),但想知道如何在Python中做到这一点

In Matlab I simply call h5disp(filename) but would like to know how to do it in Python

推荐答案

您尝试过吗?

print(list(f.keys()))

这应该为您提供hdf5文件中的所有组.如果f是一个组,则可以对数据集执行相同的操作.

That should give you all the group inside your hdf5 file. You can do the same for the datasets if f is a group.

这篇关于如何在Python中检查.h5文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆