Learn R Programming

h5lite (version 2.0.0.2)

h5_move: Move or Rename an HDF5 Object

Description

Moves or renames an object (dataset, group, etc.) within an HDF5 file.

Usage

h5_move(file, from, to)

Value

This function is called for its side-effect and returns NULL

invisibly.

Arguments

file

The path to the HDF5 file.

from

The current (source) path of the object (e.g., "/group/data").

to

The new (destination) path for the object (e.g., "/group/data_new").

Details

This function provides an efficient, low-level wrapper for the HDF5 library's H5Lmove function. It is a metadata-only operation, meaning the data itself is not read or rewritten. This makes it extremely fast, even for very large datasets.

You can use this function to either rename an object within the same group (e.g., "data/old" to "data/new") or to move an object to a different group (e.g., "data/old" to "archive/old"). The destination parent group will be automatically created if it does not exist.

See Also

h5_create_group(), h5_delete()

Examples

Run this code
file <- tempfile(fileext = ".h5")
h5_write(1:10, file, "group/dataset")

# Review the file structure
h5_str(file)

# Rename within the same group
h5_move(file, "group/dataset", "group/renamed")

# Review the file structure
h5_str(file)

# Move to a new group (creates parent automatically)
h5_move(file, "group/renamed", "archive/dataset")

# Review the file structure
h5_str(file)

unlink(file)

Run the code above in your browser using DataLab