I had this issue, too. So I modded the loop just a bit so it would ignore the hands from the night before. Basically I ignore the hands until I hit the local table Hand Number to be 1. There are three critical restrictions on having this work, though.naked_eskimo wrote:If I "stitched" two hand history files together, would this still work? Often games go from before midnight, until after midnight. This means the session history is spread over two files. If I just copied and pasted the contents of two files into one, would that work?
- The first file argument you pass to the script MUST be the one with hands from the night before
- You have to run this before hands also get added to the 2nd file (in other words, before they play again the next night) cause if there's another 1st hand encountered, it will start adding those to the balances cause once I encounter the first hand of the table, everything after just gets counted
- You can't pass in hand result files from multiple tables into the script anymore
Anyway, here's the code loop that you need to replace with what's there:
Code: Select all
# CC Added startHands variable
# we need to find the first hand to process. sometimes log file has last night's hands first that we
# want to skip over until we find the first local start hand. we'll use startHands to control when to
# start adding the hands
startHands = False
for fh in args.file:
f = open(fh.name, mode='r', encoding='utf-8')
line = f.readline()
while (len(line) != 0):
matches = re.search("Hand #(\d*)-(\d*) - (.*)$",line)
if (matches != None):
handNumber = matches.group(1)
# CC Added next 3 lines
localHandNumber = matches.group(2)
if localHandNumber == '1':
startHands = True
# CC Added if/else condition and else block and indented if block
if startHands == True:
handTime = datetime.datetime.strptime(matches.group(3),"%Y-%m-%d %H:%M:%S")
hands[handNumber] = {LOCAL: matches.group(1),
DATETIME: handTime,
TEXT: ''}
line = f.readline()
while (not (line.strip() == '')):
table = re.search("Table: (.*)$",line)
if (table != None):
tableName = table.group(1)
if (not tableName in tables):
tables[tableName] = {COUNT: 0, LATEST: ""}
hands[handNumber][TABLE] = tableName
hands[handNumber][TEXT] = hands[handNumber][TEXT] + line
line = f.readline()
else:
# just skip to next hand
while True:
line=f.readline()
if (line.strip() == ''):
break
else:
line = f.readline()
f.close()