MATLAB:
Suppose you have a HDF5 file that looks like:
>> h5disp('myh5file.h5')
HDF5 myh5file.h5
Group '/'
Dataset 'a'
Size: 227x227x6x5000
MaxSize: 227x227x6xInf
Datatype: H5T_IEEE_F32LE (single)
ChunkSize: 227x227x6x1000
Filters: none
FillValue: 0.000000
Dataset 'b'
Size: 6x5000
MaxSize: 6xInf
Datatype: H5T_IEEE_F32LE (single)
ChunkSize: 6x1000
Filters: none
FillValue: 0.000000
If you want to rename the datasets "/a" to "/a_new", do:
fid=H5F.open('myfile.h5', 'H5F_ACC_RDWR', 'H5P_DEFAULT');
gid=H5G.open(fid, '/');
H5L.move(fid, 'a', gid, 'a_new', 'H5P_DEFAULT', 'H5P_DEFAULT');
H5G.close(gid);
H5F.close(fid);
PYTHON:
h5py makes it easy to "hard-link" the same dataset to a new name.
import h5py
h5file=h5py.open("myfile.h5", "r+");
h5file["new_dataset_name"]=h5file["orig_dataset_name"];
h5file.close();
If you had wanted to delete orig_dataset_name entirely, you'd simply add (before closing h5file):
del h5file["orig_dataset_name"];
Suppose you have a HDF5 file that looks like:
>> h5disp('myh5file.h5')
HDF5 myh5file.h5
Group '/'
Dataset 'a'
Size: 227x227x6x5000
MaxSize: 227x227x6xInf
Datatype: H5T_IEEE_F32LE (single)
ChunkSize: 227x227x6x1000
Filters: none
FillValue: 0.000000
Dataset 'b'
Size: 6x5000
MaxSize: 6xInf
Datatype: H5T_IEEE_F32LE (single)
ChunkSize: 6x1000
Filters: none
FillValue: 0.000000
If you want to rename the datasets "/a" to "/a_new", do:
fid=H5F.open('myfile.h5', 'H5F_ACC_RDWR', 'H5P_DEFAULT');
gid=H5G.open(fid, '/');
H5L.move(fid, 'a', gid, 'a_new', 'H5P_DEFAULT', 'H5P_DEFAULT');
H5G.close(gid);
H5F.close(fid);
PYTHON:
h5py makes it easy to "hard-link" the same dataset to a new name.
import h5py
h5file=h5py.open("myfile.h5", "r+");
h5file["new_dataset_name"]=h5file["orig_dataset_name"];
h5file.close();
If you had wanted to delete orig_dataset_name entirely, you'd simply add (before closing h5file):
del h5file["orig_dataset_name"];
In the python code on the 2nd line where h5py.open is used the command should be h5py.File("myfile.h5", "r+"); as of 27/6/20
ReplyDelete