8350

read part of h5 dataset python

Question:

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?

Answer1:

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.

Recommend

  • Why does GetAttr not work on cloudformation template parameters?
  • Azure function C#: Create or replace document in cosmos db on HTTP request
  • Two view models ,one for the whole page & the other for a small area
  • Byte Array to *Signed* Int
  • System.IO.IOException: Too many open files
  • How to use Sanitize on HTML Entity
  • Caching of Google Cloud Endpoints?
  • Replacing ui router 0.2 with 1.0.0
  • password_hash() not working [closed]
  • Texture streaming in DirectX11, Immutable vs Dynamic
  • How to create 2 svg's on one page?
  • Authorization Policies/Gates for Laravel 5.3 web app consuming own API w/ Passport
  • Google Maps V3 (PHP/MYSQL with custome infobox)
  • Handle tunneled custom routed event
  • WooCommerce get order quantity in thank you page and redirect
  • forever does not start on server reboot [duplicate]
  • JavaFX Embed Custom Font Not Working
  • Corda: How to implement hierarchical relationships between state data persisted to H2
  • Django REST framework - HyperlinkedRelatedField with additional parameter
  • Android studio import problems. (Apktool)
  • getting the class name of an HTML tag using XPATH
  • How to create subsets of a single set of elements with XSLT?
  • how to run a different select statement based on condition in Hive SQL
  • Runtime complexity of getting the length of a string in different representations
  • concise way of flattening multiindex columns
  • r - input value by user to dataframe via shiny
  • Conflicting declaration using constexpr and auto in C++11
  • How to include associated objects using gon in Rails/jQuery
  • 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs
  • How can I ssh into a server that requires 2 password authentication using python's paramiko mod
  • Another “Cannot make static reference…” Question
  • Background transfer download task failed when app was closed
  • XEP-0166: Jingle protocol implementation for voice/video chat in iOS
  • Using Service Component Runtime
  • Time Complexity of Fibonacci Algorithm [duplicate]
  • XSLT Transformation to validate rules in XML document