1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ I think you must use small x instead of capital X. try with small -x and don't mention the output.file. if you can have the proper output in the stdout, simply redirect it to a file. $\endgroup$
    – Kasra
    Commented Mar 8, 2022 at 18:52

1 Answer 1

0
$\begingroup$

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()],sep="\n")

# 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()
$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – atrlrgn
    Commented Apr 2, 2019 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.