Please, help us to better serve our user community by answering the following short survey: https://www.hdfgroup.org/website-survey/
HDF5  1.14.4.3
API Reference
 
Loading...
Searching...
No Matches
Discovering the Contents of an HDF5 File

Navigate back: Main / Getting Started with HDF5 / Learning the Basics


Discovering what is in an HDF5 file

HDFView and h5dump are standalone tools which cannot be called within an application, and using H5Dopen and H5Dread require that you know the name of the HDF5 dataset. How would an application that has no prior knowledge of an HDF5 file be able to determine or discover the contents of it, much like HDFView and h5dump?

The answer is that there are ways to discover the contents of an HDF5 file, by using the Groups (H5G), Links (H5L) and Objects (H5O) APIs:

  • The Groups (H5G) interface (covered earlier) consists of routines for working with groups. A group is a structure that can be used to organize zero or more HDF5 objects, not unlike a Unix directory.
  • The Links (H5L) interface consists of link routines. A link is a path between groups. The Links (H5L) interface allows objects to be accessed by use of these links.
  • The Objects (H5O) interface consists of routines for working with objects. Datasets, groups, and committed datatypes are all objects in HDF5.

Interface routines that simplify the process:

  • H5Literate traverses the links in a specified group, in the order of the specified index, using a user-defined callback routine. (A callback function is one that will be called when a certain condition is met, at a certain point in the future.)
  • H5Ovisit / H5Lvisit recursively visit all objects/links accessible from a specified object/group.

Programming Example

Using H5Literate, H5Lvisit and H5Ovisit

For example code, see the HDF5 Examples page. Specifically look at the Examples by API. There are examples for different languages, where examples of using H5Literate and H5Ovisit/H5Lvisit are included.

The h5ex_g_traverse example traverses a file using H5Literate:

The h5ex_g_visit example traverses a file using H5Ovisit and H5Lvisit:


Navigate back: Main / Getting Started with HDF5 / Learning the Basics