next up previous contents
Next: Reading an HDF5 file Up: Examples Previous: Writing an HDF5 file

Reading a simple HDF5 file

The following example code will read the /info/xscale, /info/yscale and /data fields from the HDF5 file `simple_test.hdf'.

import _pyhl

# Read the file
aList = _pyhl.read_nodelist(``simple_test.hdf'')

# Select individual nodes, instead of all of them
aList.selectNode(``/info/xscale'')
aList.selectNode(``/info/yscale'')
aList.selectNode(``/data'')

# Fetch the data for selected nodes
aList.fetch()

# Print the data
aNode = aList.getNode(``/info/xscale'')
print ``XSCALE='' + `aNode.data()`
aNode = aList.getNode(``/info/yscale'')
print ``YSCALE='' + `aNode.data()`
aNode = aList.getNode(``/data'')
print ``DATA='' + `aNode.data()`




2000-08-08