Missing timestamp. EOFError: No timestamp match found in recovery attempt

Hey, I am unpacking a bunch of ping360 bin files and organising them into a dataframe but my script stops at a certain file with the following error “No timestamp match found in recovery attempt”. Does anyone know what has happened here and what i can do about it? None of the other files raise this error, but i suspect it is at the very end of the file the error occurs. I am using a modified version of the script found here:

Any ideas?

Hi @Winter,

I wrote that recovery code (while working for a different company) because I was running into problems where occasionally there was data in the sensor log that didn’t match the log file specification. I didn’t have time to investigate the cause of the issue*, so decided to just write some recovery code to attempt to find the next valid message within the remainder of the file, and continue parsing afterwards.

*it could be a random message that corrupted during writing, a single corrupted message at the end of the file due to a crash, and/or Ping Viewer may be putting in some non-compliant data that it’s not supposed to, I’m still not sure and haven’t had time to check

I’ve made a pull request here which adds some extra information to the error message, and should help you to determine whether the information that’s failing recovery is a significant portion of the file, or whether it’s just a small amount at the end that can be ignored. :slight_smile:

Note that the EOFError is an expected result if reading fails, so if you want to ignore it then you’ll need to catch and except it in your parsing code.

I tried just except and pass the error but this only leads to a typeError: “cannot unpack non-iterable NonType object” in the for loop in parse(). I will try the changes you made in the linked script and see if it gives some more information. If not, is there a way to just end at a certain timestamp you think?

It’s hard to respond to this, because it’s not clear where you tried to handle the exception. The exception is raised partly because if the iterator has no meaningful data to output (because it failed to read it) then it has nothing reasonable to provide to a loop that’s iterating over it. To catch and handle an exception like that you need to have the parsing iteration inside a try block, and an except block to handle the case where the parsing unexpectedly ends early, e.g.

    for (timestamp, decoded_message) in log.parser():
        ... # do something with data
except EOFError as e:

... # continue rest of the program, knowing that parsing is finished

If you’re doing the iterating, you can break out of the loop whenever you want. To stop at an exact timestamp you can just do

if timestamp == '<timestamp_to_stop_at>':

but if you don’t know every timestamp in the file you may wish to stop after some time has been reached, in which case you would want to convert the string timestamps to more meaningful datetime/timedelta objects that you can then do comparisons on.