import struct, sys path = "/home/aria/kellogg_remake/raw/PCKELL.DAT" data = open(path, "rb").read() print("total size:", len(data)) # Read uint16 LE values until they stop being monotonically non-decreasing vals = [] off = 0 prev = -1 while off + 2 <= len(data): v = struct.unpack_from(" 5000: break # find longest monotonic non-decreasing prefix mono_len = 1 for i in range(1, len(vals)): if vals[i] >= vals[i-1]: mono_len = i+1 else: break print("monotonic non-decreasing prefix length (uint16 entries):", mono_len) print("that's byte offset:", mono_len*2) print("first 40 vals:", vals[:40]) print("vals around break point:", vals[max(0,mono_len-10):mono_len+10])