Writing Compound Data into Groups in HDF5 files
12 views (last 30 days)
Show older comments
I'm trying to write MATLAB data to an existing database of hdf5 files. Data in the database is currently being stored as table. The tables' columns can be different data types such as an integer or a string etc. and the columns also have labels like "longitude", "Name of patient" etc as a property of the table.
I posted a question about this and was helped out by being pointed towards the following link: http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-m.html. I used the Write Compound Data script to solve the problem.
However, I need to nest the data inside a number of directories inside the hdf5 file. For example /hospital/patient/patientdata. I think the hdf5 terminology is "groups"
I worked out how to do this using MATLAB h5write command but this only works for numeric datasets and not the compound data that I'm trying to write. Could someone tell me what changes I need to make to the example script http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/matlab/HDF5_M_Examples/h5ex_t_cmpd.m to get it writing the data inside of a set of groups?
0 Comments
Accepted Answer
John
on 19 Jul 2012
Change line 89 from
dset = H5D.create (file, DATASET, filetype, space, 'H5P_DEFAULT');
to (for example)
plist = 'H5P_DEFAULT';
g1 = H5G.create(file,'g1',plist,plist,plist);
g2 = H5G.create(g1,'g2',plist,plist,plist);
dset = H5D.create (g2, DATASET, filetype, space, 'H5P_DEFAULT');
You then get a dataset with full path name '/g1/g2/DS1'
You also have to change the line in the script that tries to re-open the dataset, just give it the full path name.
More Answers (0)
See Also
Categories
Find more on HDF5 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!