[Python] hdf5 'Unable to open object (bad object header version number)' error handling

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm reading data from a h5 file that apparently is faulty. It consist of several hundreds of cycles(each with 30members) and one of the cycles(#100) is empty (the group exists but it contains no group members).

    When iterating through the cycles, the moment that cycle is reached i get a 'Unable to open object (bad object header version number)' How can i prevent that my script stops when this cycle is reached?

    I tried checking in advance whether each group actually has members in order to exclude empty cycles from the iteration but i get a runtimeError already trying to do so:

    g = h5py.File('file.h5', 'r')
    g['cycle_100']
    *** RuntimeError: Can't determine # of objects (bad symbol table node signature)


    searching for a solution i found that only exception can be handled not errors - is there nothing i can do but manually exclude this cycle after the error has happened and run the script again? This would be easy but whenever i receive a faulty file i would have to do it again.

    Any pointers what i should search for would be appreciated I'm a beginner.

    Continue reading...

Compartilhe esta Página