Reputation: 23
I'm currently trying to write a model import script for blender and the vertex coordinates within the file I need to parse through are preceded by the 8 bit header 68 * 80 04, with the decimal value of whatever "*" is identifying the number of vertices. Given that the header isn't entirely consistent throughout the file I was wondering what methods are there to perform a wildcard search of a bytes hexadecimal representation once it's read in?
Upvotes: 1
Views: 1118
Reputation: 465
You could use regular expressions:
import re
with open('filename', 'rb') as file:
bs = file.read()
matches = re.findall(b'\x68.\x80\x04', bs)
Upvotes: 1