Learn R Programming

BigDataStatMeth (version 2.0.3)

list_datasets: List datasets in an HDF5 file or group

Description

Lists datasets within an HDF5 file. If no group is specified, the entire file is traversed recursively and full relative paths are returned (e.g. "INPUT/A", "RESULTS/SVD/d"). If a group is given, only the datasets in that group are listed unless recursive = TRUE.

Usage

list_datasets(x, group = NULL, prefix = NULL, recursive = FALSE)

Value

Character vector of dataset names or relative paths.

Arguments

x

An HDF5Matrix object, or a character string (file path).

group

Character or NULL. Group path inside the HDF5 file. If NULL and x is a file path, the whole file is listed recursively. If NULL and x is an HDF5Matrix, the object's own group is used (non-recursive).

prefix

Optional character. Only return datasets whose name starts with this prefix.

recursive

Logical. If TRUE, recurse into subgroups and return full relative paths. Default FALSE.

See Also

hdf5_matrix, hdf5_create_matrix

Examples

Run this code
# \donttest{
fn <- tempfile(fileext = ".h5")
hdf5_create_matrix(fn, "INPUT/A",    data = matrix(rnorm(100), 10, 10))
hdf5_create_matrix(fn, "INPUT/B",    data = matrix(rnorm(100), 10, 10))
hdf5_create_matrix(fn, "RESULTS/C",  data = matrix(rnorm(100), 10, 10))

# All datasets in the file (recursive from root)
list_datasets(fn)

# Only INPUT group
list_datasets(fn, group = "INPUT")

# From an HDF5Matrix object (uses object's own group)
X <- hdf5_matrix(fn, "INPUT/A")
list_datasets(X)

hdf5_close_all()
unlink(fn)
# }

Run the code above in your browser using DataLab