读取h5数据集python的一部分 [英] read part of h5 dataset python

查看:706
本文介绍了读取h5数据集python的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从.h5文件中读取大量数据(每个数据集200,000点),而我目前不需要所有数据,因此我一直在做的工作是读取数据,然后将其截断之后.

I'm reading in large sets of data from an .h5 file, (200,000 points per dataset) and I currently don't need all of it so what I've been doing is reading in the data, then truncating it after.

有没有办法只读取h5数据集的前X个项目?

Is there a way to only read the first X items of an h5 dataset?

推荐答案

使用此...

import numpy as np
import h5py

filename = 'file.hdf5'
f = h5py.File(filename, 'r')

key = list(f.keys())[0]

data = list(f[key][1])

keyf[key]的索引可能有所不同,其中[0]file.hdf5的任意数据集,而[1]只是我抓取的任意列.

Indexing may vary for key and f[key], where [0] is an arbitrary dataset of file.hdf5 and [1] is just an arbitrary column I grabbed.

这篇关于读取h5数据集python的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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