Are there any good Python solutions like Ruby BinData for reading custom binaries / streams? If not, what is the preferred way to do this in Python outside of using the struct module?
I have a binary file that stores the "records" of events. Records are dynamic in size, so I have to read the first few bytes of each record to determine the length of the record and the type of record. Different types of records will have different byte layouts. For example, a warning record may contain three 4-byte ints followed by a 128-byte value, while an information record may contain only five 4-byte ints.
It would be nice to define different types of records and their structures in such a way that I could just pass the binary code to something, and it processes the rest (generating objects, etc.). In short, your defining patterns / maps on how to interpret binary data.
dj29 source share