Python Forum
Check if a Group/dataset path exists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if a Group/dataset path exists
#1
Hi

I'm working on hdf5 files having group and subgroups, so I'm providing the path to the datasets or the groups. In practise, I know how to check if a group and/or a dataset exists using ".keys()", but is it possible to check if the path (or an object) exists or not?

I've been digging in the doc, but still looking for the answer

Thanks

The following generates an error since the path is not valid
    if hdf5['MyPath']:
        print("ok Path exists")
Error:
KeyError: "Unable to open object (object 'MyPath' doesn't exist)"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to group variables & check correlation of group variables wrt single variable SriRajesh 2 2,931 May-23-2018, 03:01 PM
Last Post: SriRajesh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020