how can I delete a dataset completely from a group in a .hdf5 file?

106 ビュー (過去 30 日間)
Taylor Waber
Taylor Waber 2018 年 4 月 18 日
回答済み: shubham kumar gupta 2021 年 6 月 6 日
I am trying to combine parts 2 .hdf5 files. I thought to just grab the data from each file, then re-write this data onto one of my files or make a copied file and write it there. I want to avoid creating datasets in the first place with 'infinite' size. To write data to a dataset, it needs to be the same size as the dataset, but when I'm combinging my .hdf5 datasets they are doubling in size. So can I delete an entire dataset so that I can then create a new one with the combined data size?
Thanks

回答 (5 件)

shubham kumar gupta
shubham kumar gupta 2021 年 6 月 6 日
dataset_to_delete='info';
fid = H5F.open('myfile.h5','H5F_ACC_RDWR','H5P_DEFAULT');
H5L.delete(fid,dataset_to_delete,'H5P_DEFAULT');

plasmageek
plasmageek 2018 年 4 月 20 日
I'm pretty sure you can't, even with the low level functions. But if somebody knows of a way, I'm also trying to figure this out.

Walter Roberson
Walter Roberson 2018 年 4 月 20 日
編集済み: Walter Roberson 2018 年 4 月 20 日

It looks like there is support at the HDF5 level for deleting datasets, but that there is no support for reclaiming the space.

http://hdf-forum.184993.n3.nabble.com/hdf-forum-HDF5-Deleting-Datasets-AND-Recovering-Space-td194317.html

If there is no available MATLAB routine then it appears you could call into python; https://stackoverflow.com/questions/31861724/deleting-hdf5-dataset-using-h5py

  1 件のコメント
per isakson
per isakson 2018 年 5 月 5 日
"[...] there is no support for reclaiming the space." There is a tool that sort of does it, see h5repack, Copies an HDF5 file to a new file with or without compression and/or chunking.

サインインしてコメントする。


Dave Bodette
Dave Bodette 2019 年 1 月 15 日
See the Example under H5L.delete for a way to accomplish what you want. You basically delete your entire Group and start over.
In the end you will need to run h5repack to recover the deleted space and avoid your .h5 file bloating.

Jerome NoName
Jerome NoName 2020 年 9 月 16 日
編集済み: Walter Roberson 2020 年 9 月 16 日
Dear all,
I wanted to make you aware of a development one of my colleague did and put it online in opensource. It's called h5nav. You can download if with pip install ( https://pypi.org/project/h5nav/ )
In a terminal:
---
pip install h5nav
h5nav toto.h5
ls
rm the_group_you_want_to_delete
exit
---
Note that you'll still have to use h5repack to lower the size of your file.
Best,
Jérôme

カテゴリ

Help Center および File ExchangeHDF5 についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by