python - 读取h5数据集python的一部分

标签 python python-3.x large-files h5py

我正在从 .h5 文件中读取大量数据(每个数据集 200,000 个点),而且我目前不需要全部数据,因此我一直在读取数据,然后截断它之后。

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

最佳答案

使用这个...

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] 只是我抓取的任意列。

关于python - 读取h5数据集python的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50418649/

相关文章:

python-3.x - 如何断言在 pytest 中调用了猴子补丁?

python - 以 pythonic 方式使用 i > j ( > k) 迭代多个索引

python - 打印包含字符串和 2 个其他变量的变量

在不读取整个文件的情况下以相反的顺序 grep

node.js - 如何在nodejs中向后读取大型json文件

python - HTTPretty 测试卡在 Travis 上

python - PyQt 中的 QUiLoader.createWidget 等价物

pandas - 如何在pandas中调用带有 block 的描述函数?

python - Node.js 的 python 子脚本在完成时输出,不是实时的

python - 可以在不模拟对象的其他属性的情况下模拟 python 构造函数吗?