This script turns this
into thisCode: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 Tattoo
If you run into any bugs, send me the log you are using it on and the line it stops on.Code:2 Green Octopus (on my head) 2 Gaia Wing Beanie 3 Blue Skull & Bones Arm Tattoo
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.
Code: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()
Results 1 to 5 of 5
Threaded View
- 14 May. 2011 10:27pm #1
[PY3.1] Trash Picker log consilidation
LG's resident grammar nazi.
Need warez? I can probably find it for you. Throw me a PM.
For all of my sales, if you refer a buyer to me and they make a purchase, you can recieve 5%