| 1 |
"""
|
| 2 |
|
| 3 |
GapReport
|
| 4 |
|
| 5 |
Created by
|
| 6 |
Emanuel Borges
|
| 7 |
04.27.2018
|
| 8 |
|
| 9 |
Simple program for detecting gaps in a list of bates number sets (BegNo, EndNo)
|
| 10 |
|
| 11 |
Covert Unicode to ASCII first!
|
| 12 |
|
| 13 |
"""
|
| 14 |
#import sys
|
| 15 |
#sys.path.append(r"C:\\Users\\eborges\\Dropbox\\NinoCode\\Active_prgs\\Summation\\Summation_functions")
|
| 16 |
|
| 17 |
import BatesRangeFunctions
|
| 18 |
|
| 19 |
if __name__ == '__main__':
|
| 20 |
batesMatrix = {}
|
| 21 |
datFile = r"C:\Temp\Lee-Mercer\LeeRoomTest-BAD.dat"
|
| 22 |
|
| 23 |
## Grab the begno and endno fields, starting with 0 place
|
| 24 |
begNoColumn = 2
|
| 25 |
endNoColumn = 3
|
| 26 |
|
| 27 |
delim = '\x14'
|
| 28 |
quoteChar = '\xfe'
|
| 29 |
|
| 30 |
contents = open(datFile).readlines()
|
| 31 |
for line in contents[1:]:
|
| 32 |
line = line.replace("\n","")
|
| 33 |
line = line.replace(quoteChar, "")
|
| 34 |
line = line.split(delim)
|
| 35 |
begNo = line[begNoColumn]
|
| 36 |
endNo = line[endNoColumn]
|
| 37 |
batesMatrix[begNo] = endNo
|
| 38 |
|
| 39 |
|
| 40 |
begBatesList = list(batesMatrix.keys())
|
| 41 |
begBatesList.sort()
|
| 42 |
|
| 43 |
endNoBuffer = ""
|
| 44 |
for begBates in begBatesList:
|
| 45 |
if endNoBuffer:
|
| 46 |
pageGap = BatesRangeFunctions.EnumerateBates(endNoBuffer, begBates)
|
| 47 |
if len(pageGap) > 2:
|
| 48 |
print("A %d page gap exists between EndNo of %s and BegNo of %s"% (len(pageGap),endNoBuffer, begBates))
|
| 49 |
endNoBuffer = batesMatrix[begBates]
|
| 50 |
else:
|
| 51 |
endNoBuffer = batesMatrix[begBates] |