comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to check for existence of an HDF5 group
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to check for existence of an HDF5 group [message #90186 is a reply to message #90185] Sun, 08 February 2015 17:24 Go to previous messageGo to previous message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Sunday, February 8, 2015 at 4:39:51 AM UTC-5, superchromix wrote:
> On Saturday, February 7, 2015 at 7:24:50 PM UTC+1, David Grier wrote:
>> Dear Folks,
>>
>> I want to create new groups within an HDF5 file. Before creating a new group, however,
>> I'd like to check whether a group of the same name already exists. What's the right
>> way to do this?
>>
>> Calling H5G_OPEN or H5G_GET_OBJINFO with a new group name throws an error.
>> I could write a wrapper routine that catches the error and returns a "group not found"
>> value but that seems kludgy.
>>
>> H5_LIST returns a whole lot of information, which I suppose I could parse. That also seems
>> clunky.
>>
>> Is there a more elegant solution? Something along the lines of FILE_TEST that works
>> for HDF5 groups (H5G_TEST, e.g.)?
>>
>> All the best,
>>
>> David
>
>
> hi David,
>
> The way to do it is to use H5_LIST with the FILTER keyword.
>
> Also, I have a routine for this in my library: wmb_h5_group_exists()
>
> which can be found at http://www.github.com/superchromix/wmb_lib
>
> best,
> Mark

Thanks for the pointer to your repository, Mark. I'll have to look through
the HDF5 routines closely. In the meanwhile, the following kludge is working
for me. I try to open the group, and catch the error if the group
doesn't exist. This is part of an object definition for storing multi-volume
video data in an HDF5 archive:

;;;;
function h5video::H5G_OPEN, loc_id, group

COMPILE_OPT IDL2, HIDDEN

catch, error
if (error ne 0L) then begin
return, 0L
catch, /cancel
endif

gid = h5g_open(loc_id, group)
return, gid
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL to python bridge Library not loaded: libidl.8.5.dylib
Next Topic: =?UTF-8?B?UmU6INmF2LTYp9mH2K/YqSDYqNix2YbYp9mF2Kwg2LHYp9mF2LIg2KrYrdiqINin2YTYpw==?= رض حلقه 4 الشاب خالد

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Nov 28 08:14:19 PST 2025

Total time taken to generate the page: 0.00834 seconds