Skip to contents

Lists the names of objects (datasets and groups) within an HDF5 file or group.

Usage

h5_ls(file, name = "/", recursive = TRUE, full.names = FALSE)

Arguments

file

Path to the HDF5 file.

name

The group path to start listing from. Defaults to the root group (/).

recursive

If TRUE (default), lists all objects found recursively under name. If FALSE, lists only the immediate children.

full.names

If TRUE, the full paths from the file's root are returned. If FALSE (the default), names are relative to name.

Value

A character vector of object names. If name is / (the default), the paths are relative to the root of the file. If name is another group, the paths are relative to that group (unless full.names = TRUE).

See also

Examples

file <- tempfile(fileext = ".h5")

# Create some nested objects
h5_write(file, "g1/d1", 1)
h5_write(file, "g1/g2/d2", 2)

# List recursively from the root (default)
h5_ls(file) # c("g1", "g1/d1", "g1/g2", "g1/g2/d2")
#> [1] "g1"       "g1/d1"    "g1/g2"    "g1/g2/d2"

# List recursively from a subgroup
h5_ls(file, name = "g1") # c("d1", "g2", "g2/d2")
#> [1] "d1"    "g2"    "g2/d2"

unlink(file)