Commit 765e14a9 authored by Zhukov, Alexander P's avatar Zhukov, Alexander P
Browse files

Started work on random access to binary file

parent cd15a4ca
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -7,6 +7,7 @@ Created on Wed Jan 22 17:25:26 2020
"""
from array import array
from datetime import datetime as dt
import os
def read_size(file, long=True):
......@@ -147,15 +148,22 @@ def read_record(file):
break
return record
def read_epilog(file):
OFST_SIZE=8
file.seek(-4,os.SEEK_END)
raw = array('I',file.read(4))
raw.byteswap()
num_records = raw[0]
print(num_records)
file.seek(-4-OFST_SIZE*num_records,os.SEEK_END)
raw = array('L',file.read(OFST_SIZE*num_records))
raw.byteswap()
print(raw.itemsize)
print(raw)
file = open('/data/BinStorage/test.bin','rb')
bytes = file.read(12)
print(bytes.decode())
while True:
record = read_record(file)
if 'EOF' in record:
break
print(record)
file.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment