NeuroJSON / easyh5

EasyH5 Toolbox - An easy-to-use HDF5 data interface (loadh5 and saveh5) for MATLAB
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

Append to existing h5 file #11

Closed pbl007 closed 2 years ago

pbl007 commented 4 years ago

Hello

Love your code!!!

A quick feature request: could it be possible to allow saveh5 to "append" a group to an existing h5 file?

For example: assume file1.h5 already exists and has several groups/datasets etc. then

saveh5(data2hdf,'file1.h5','rootname','group_name1/group_name2...') should write data2hdf into the specific path.

I tried and the content of file1.h is overwritten. I might have missed some option in your code.

Thanks again! Pablo

fangq commented 2 years ago

it has been a while, but the requested feature is finally supported, checkout this

saveh5(rand(5), 'test.h5', 'rootname','/mat')
saveh5('rand', 'test.h5', 'rootname','/name','append',1)
s=loadh5('test.h5')
s = 

  struct with fields:

     mat: [5×5 double]
    name: 'rand'

this toolbox is also tested and works on old MATLAB going back to R2010b