简体   繁体   中英

Remove an external linked HDF5 using Python (h5py)

Deleting data from a HDF5 file requires repacking of the master file. Since we use large sub-db files (measurement data), separate HDF5 datafiles are externally linked into the masterfile. As the linked files take up little space you could argue if a repack will be necessary.

As HDF5 database can get corrupted, what is the procedure to remove the externally linked databases ( h5py.ExternalLink ) correctly from the master HDF5 db file?

The ExternalLink object behaves like other objects (groups and datasets). So, you can use del and reference the file/link object. For example, if you have an External Link named ['/my_linked_ds'] you can delete like this:

h5f = h5py.File('yourfile.h5', 'r+')
del (h5f['/my_linked_ds'])
h5f.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM