Skip to main content

HDF5File

Represents an HDF5 file handle.

Use this class to create, read and write datasets. Datasets are addressed by path, with optional group segments (e.g. "group/data"). New datasets are compressed by default (deflate level 4).") .example(R"(var f = HDF5File("data.h5", "w") f.write("/answer", 42) var value = f.read("/answer", as_integer)

Constructors

HDF5File(const string path) -> HDF5File

Opens an HDF5 file in read/write mode, creating it if needed.

Parameters

  • path: File path.

Example

var f = HDF5File("data.h5")

HDF5File(const string path, const string mode) -> HDF5File

Opens an HDF5 file with an explicit mode.

Modes:

  • "r": read-only
  • "r+": read/write (existing file)
  • "w": truncate and overwrite
  • "w-" or "x": create, fail if it exists
  • "a": read/write, create if missing (default)

Parameters

  • path: File path.
  • mode: File open mode.

Example

var f = HDF5File("data.h5", "w")

Members

NameDescription
compression_enabledReturns whether dataset compression is enabled for new datasets (level > 0).
compression_levelReturns the compression level used for new datasets (0-9).
create_groupCreates a group (including intermediate groups).
delete_attributeDeletes an attribute and returns the file for chaining.
delete_datasetDeletes a dataset.
delete_groupDeletes a group.
existsChecks whether a dataset or group exists at the given path.
groupOpens or creates a group.
has_attributeChecks whether an attribute exists on a file, group, or dataset.
is_datasetChecks whether a path is a dataset.
is_groupChecks whether a path is a group.
list_attributesLists attribute names for a file, group, or dataset.
list_datasetsLists datasets in the root group.
list_groupsLists groups in the root group.
list_objectsLists objects in the root group.
moveMoves or renames an object.
object_typeReturns the object type at a path.
open_groupOpens an existing group.
rankReturns dataset rank.
readReads a real scalar dataset.
read_attributeReads a string scalar attribute.
set_compression_levelSets dataset compression level (0-9) for newly created datasets. Level 0 disables compression.
shapeReturns dataset dimensions.
sizeReturns dataset element count.
writeWrites a real list dataset.
write_attributeWrites an attribute and returns the file for chaining.