Extract single dataset including attributes

Hi,

I have an HDF5 file that consists of multiple datasets and a few attributes. It looks like this:
GROUP “/” {
DATASET “A” {
ATTRIBUTE “Attr1”
}
DATASET “B” {
ATTRIBUTE “Attr1”
}
}

I’m trying to extract dataset A and its attributes, and save them in another HDF file.
I can extract the data of A, but not its attributes.

I tried to manually edit the DDL file (see below), but then I get an empty HDF file.

My script to do the conversion is:
h5dump -p -d “/A” --ddl=file.ddl -o dset.bin -b orig.hdf5
h5import dset.bin -c file.ddl -o extracted.hdf5

What am I doing wrong?

Regards,
Hans

The h5copy utility will copy a dataset and its attributes to another HDF5 file (existing or not). For example, this command will copy the dataset “/Dataset” and its attributes from Attributes.h5 to myattr.h5.

h5copy -i Attributes.h5 -o myattr.h5 -s “/Dataset” -d “/Dataset”

The h5copy utility comes with the binary distribution of HDF5 (along with h5dump and h5import).

You can also use the HDFView browser to copy a dataset and its attributes to another file.
The HDFView utility can be obtained from here:

https://www.hdfgroup.org/downloads/hdfview/

-Barbara

Hi Barbara,

Thanks a lot. Your answered is indeed the solution. Somehow I overlooked the h5copy utility.

Regards,
Hans