[PY3.1] Trash Picker log consilidation
This script turns this
into this
If you run into any bugs, send me the log you are using it on and the line it stops on.
Requires Python 3.1 to run.
Opens up the trash picker log, log.txt and spits out b.txt with the revised inventory.
Save code as trashlogger.py or whatever you want, and run in your trash picker directory.
XXXXXX Just got a(n) : 1 Green Octopus (on my head)
XXXXXX Just got a(n) : 1 Green Octopus (on my head)
XXXXXX Just got a(n) : 1 Gaia Wing Beanie
XXXXXX Just got a(n) : 1 Blue Skull & Bones Arm Tattoo
XXXXXX Just got a(n) : 1 Blue Skull & Bones Arm Tattoo
XXXXXX Just got a(n) : 1 Blue Skull & Bones Arm Tattoointo this
2 Green Octopus (on my head)
2 Gaia Wing Beanie
3 Blue Skull & Bones Arm TattooIf you run into any bugs, send me the log you are using it on and the line it stops on.
Requires Python 3.1 to run.
Opens up the trash picker log, log.txt and spits out b.txt with the revised inventory.
Save code as trashlogger.py or whatever you want, and run in your trash picker directory.
import re
origin= open('log.txt', 'r')
output = open('b.txt', 'w')
pattern = r"(:)\s(\d+)\s([^\n']+)"
items = dict()
itemlist = ['House Fly']
for line in origin:
print(line)
a = re.search(pattern, line)
if a:
print(a.group(3))
print(a.group(2))
if a.group(3) in items:
items[a.group(3)] = items[a.group(3)] + int(a.group(2))
else:
items[a.group(3)] = int(a.group(2))
itemlist.append(a.group(3))
print(items)
print(itemlist)
itemlist.sort(key=lambda x: x.lower())
for item in itemlist:
if items[item] > 1:
i="'s"
else:
i=""
output.write(str(items[item])+' '+item+i+'\n')
origin.close()
output.close()[/item][/item]