Python Forum

Full Version: Find offset of binary data in file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Going back to a thread about .wav files (https://python-forum.io/Thread-From-theory-to-practice) it was brought up that some files contain additional information above that provided for in the original format.  I thought I would try and account for the 'extras'.  I thought I would start by checking the file for the word "data" and found this solution on SO which seems to work in determining if it exists or not.  
The problem I can't seem to grasp is how to determine the offset (or where the text begins) in the file.  For instance, I know in my test file, the word "data" begins at dec 36, hex 0x24.  

I've searched the Google and can't seem to find anything.  So I'm wondering if anyone has any suggestions as to where I might start looking.

Thanks
I think that s.find(b'data') returns starting position of first occurence of b'data', so 36 with your data.
Absolutely right!   Clap

Thank you very much.
position = file_handle.tell()