Parser
Class for parsing HDF5 files.
HDF5Parser(file_path, schema=None)
¶
Bases: FormatManager
Class for parsing HDF5 files.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
Path to the HDF5 file.
TYPE:
|
file_path (str): Path to the HDF5 file.
create()
¶
Create an HDF5 file.
find_file_stats()
¶
save the file stats to a file in the same directory as the hdf5 file
is_path_valid(path)
¶
Check if the path exists in the HDF5 file. Note that this is a recursive function. Thus takes a long time to run on large files.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to check in the HDF5 file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the path exists in the HDF5 file, False otherwise. |
read(path)
¶
Read a dataset or a group from the HDF5 file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to the dataset or group to read.
TYPE:
|
Returns: A numpy array or a list of numpy arrays with the dataset.
read_attributes(dataset)
¶
Read attributes from the dataset.
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
Name of the dataset to read attributes from.
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str | int | float]
|
Dictionary containing attributes and their values. |
write(data, data_scheme)
¶
Write data to the HDF5 file.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Data to write. If the dataset already exists, the data will be appended to the dataset.
|
data_scheme
|
Name of the dataset to write. If the dataset does not exist, it will be created.
|
Returns: None
write_attributes(dataset, attributes)
¶
Write attributes to the dataset.
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
Name of the dataset to write attributes to i.e. the group. If the dataset does not exist, it will be created.
|
attributes
|
Attributes to write.
|
Returns: None