readhdf5: Read data from an HDF5 file

View source: R/readhdf5.R

readhdf5R Documentation

Read data from an HDF5 file

Description

Reads data from an HDF5 file, including attributes, into a nested list that preserves the hierarchical structure of the HDF5 data.

Usage

readhdf5(file, subtree = "*", group.attr.as.data = FALSE, empty = FALSE)

Arguments

file

Character string specifying the file name of the input HDF5 file.

subtree

A structure specifying the HDF5 groups and datasets to be read. Use an asterisk "*" (default) to read the entire file. To read only part of the file, provide a named list reflecting the hierarchy of groups, subgroups, and datasets. For (sub)groups, use nested lists containing the items to read, or use '*' to load everything in the group. An empty list list() reads only the attributes of a group. For datasets, use NULL to read only attributes, or any other content to read the full data.

group.attr.as.data

Logical flag. If TRUE, group attributes are converted to datasets, which is useful for formats where parameters are stored as attributes (e.g., Gadget simulation outputs).

empty

Logical flag. If TRUE, only names of groups and datasets are returned, with all data equal to NA. This is a fast way of reading the hierarchical structure.

Details

This function, based on the hdf5r package, recursively parses and reads HDF5 files into nested lists that preserve the original hierarchy. Attributes in groups and datasets are included in the output.

Value

Nested list representing the contents of the HDF5 file. Groups are nested sublists, datasets are represented by their data. Attributes of groups and datasets are attached as attributes to the corresponding sublists and data elements.

See Also

writehdf5 for examples.


obreschkow/cooltools documentation built on Nov. 16, 2024, 2:46 a.m.