# Extracting data and saving data from hdf5

I have a hdf5 file, and I want to extract a part of the data and save it as the same format.

The data type is

DATATYPE  H5T_IEEE_F32BE


So far I have successfully extracted the data using h5dump but it is in ascii format. I couldn't save it as the same hdf5 format. I saw there are several flags for saving as xml formats, but it doesn't work for me. I have tried using flags like -x or -d such as

h5dump -d variable -s 1 10 -X output.file  input.file


It creates the output file, but it is an empty file.

edit: I need to do it using h5dump.

You can always try using the h5py module in Python.

import h5py

# Load existing file
filename = "myfile.hdf5"
dataset = h5py.File(filename, "r")

# Show keys
[print(item) for item in dataset.items()]

# Assuming that you want to select the first 10 rows of key "A"
data = dataset["A"][:10]
dataset.close()

# Create the new dataset / file
dataset2 = h5py.File("myfile2.hdf5", "w")
dataset2.create_dataset("A", data)
dataset2.close()

• thank you for your answer, but unfortunately I cannot use python at the moment. I need to do it using h5dump. It wasn't very clear in the question, I'll edit it. – atrlrgn Apr 2 '19 at 8:40