format change
This commit is contained in:
@@ -8,7 +8,7 @@ import argparse
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
def readLogFile(filename, verbose = True):
|
def readLogFile(filename, verbose = True):
|
||||||
f = open(filename, 'rb')
|
f = open(filename, 'rb')
|
||||||
|
|
||||||
print('Opened'),
|
print('Opened'),
|
||||||
print(filename)
|
print(filename)
|
||||||
@@ -22,39 +22,39 @@ def readLogFile(filename, verbose = True):
|
|||||||
ncols = len(fmt)
|
ncols = len(fmt)
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print('Keys:'),
|
print('Keys:'),
|
||||||
print(keys)
|
print(keys)
|
||||||
print('Format:'),
|
print('Format:'),
|
||||||
print(fmt)
|
print(fmt)
|
||||||
print('Size:'),
|
print('Size:'),
|
||||||
print(sz)
|
print(sz)
|
||||||
print('Columns:'),
|
print('Columns:'),
|
||||||
print(ncols)
|
print(ncols)
|
||||||
|
|
||||||
# Read data
|
# Read data
|
||||||
wholeFile = f.read()
|
wholeFile = f.read()
|
||||||
# split by alignment word
|
# split by alignment word
|
||||||
chunks = wholeFile.split(b'\xaa\xbb')
|
chunks = wholeFile.split(b'\xaa\xbb')
|
||||||
log = list()
|
log = list()
|
||||||
if verbose:
|
if verbose:
|
||||||
print("num chunks:")
|
print("num chunks:")
|
||||||
print(len(chunks))
|
print(len(chunks))
|
||||||
chunkIndex = 0
|
chunkIndex = 0
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
print("len(chunk)=",len(chunk)," sz = ", sz)
|
print("len(chunk)=",len(chunk)," sz = ", sz)
|
||||||
if len(chunk) == sz:
|
if len(chunk) == sz:
|
||||||
print("chunk #",chunkIndex)
|
print("chunk #",chunkIndex)
|
||||||
chunkIndex=chunkIndex+1
|
chunkIndex=chunkIndex+1
|
||||||
values = struct.unpack(fmt, chunk)
|
values = struct.unpack(fmt, chunk)
|
||||||
record = list()
|
record = list()
|
||||||
for i in range(ncols):
|
for i in range(ncols):
|
||||||
record.append(values[i])
|
record.append(values[i])
|
||||||
if verbose:
|
if verbose:
|
||||||
print(" ",keys[i],"=",values[i])
|
print(" ",keys[i],"=",values[i])
|
||||||
|
|
||||||
log.append(record)
|
log.append(record)
|
||||||
|
|
||||||
return log
|
return log
|
||||||
|
|
||||||
|
|
||||||
numArgs = len(sys.argv)
|
numArgs = len(sys.argv)
|
||||||
|
|||||||
Reference in New Issue
Block a user