Failed to add Group to h5 file via H5G.create
1 回表示 (過去 30 日間)
古いコメントを表示
%%1st step: create a h5 file and close it
fn = 'D:\QMDownload\3\example.h5';
fid = H5F.create(fn);
gid = H5G.open(fid,'/');
plist = 'H5P_DEFAULT';
gid1 = H5G.create(gid,'group1',plist,plist,plist);
gid2 = H5G.create(gid1,'group11',plist,plist,plist);
gid3 = H5G.create(gid2,'group111',plist,plist,plist);
H5G.close(gid);
H5G.close(gid1);
H5G.close(gid2);
H5G.close(gid3);
H5F.close(fid);
h5disp(fn)
% now add another group
fid = H5F.open(fn);
gid = H5G.open(fid,'/group1');
plist = 'H5P_DEFAULT';
gid1 = H5G.create(gid,'group12',plist,plist,plist);
Error appears:
Error using hdf5lib2
The HDF5 library encountered an error and produced the following stack trace information:
H5G__obj_create_real no write intent on file
H5G__obj_create unable to create group
H5G__create unable to create group object header
H5O_group_create unable to create group
H5O_obj_create unable to open object
H5L_link_cb unable to create object
H5G_traverse_real traversal operator failed
H5G_traverse internal path traversal failed
H5L_create_real can't insert link
H5L_link_object unable to create new link to object
H5G__create_named unable to create and link to group
H5Gcreate2 unable to create group
Error in H5G.create (line 27)
group_id = H5ML.hdf5lib2('H5Gcreate', varargin{:});
0 件のコメント
採用された回答
Jeremiah Hess
2021 年 8 月 22 日
Hey! It's been a while since this question was asked, but I encountered the same problem and managed to figure out the solution, so I'm posting it here to help any future members.
The simple explanation for the error is that the low-level function H5F.open defaults to opening the file in read-only mode, making it impossible to create new groups or datasets in the file. A simple look at the H5F.open documentation yields the following solution:
% now add another group
plist = 'H5P_DEFAULT';
fid = H5F.open(fn,'H5F_ACC_RDWR',plist); % Opens the file in read-write mode
gid = H5G.open(fid,'/group1');
gid1 = H5G.create(gid,'group12',plist,plist,plist);
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で HDF5 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!