read part of h5 dataset python

时光毁灭记忆、已成空白 提交于 2019-12-08 05:22:48

问题


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.

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


回答1:


Use this...

import numpy as np
import h5py

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

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

data = list(f[key][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.



来源:https://stackoverflow.com/questions/50418649/read-part-of-h5-dataset-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!