Paste Code
Paste Blends
Paste Images
import re

info = {} #dictionaries of game statistics
records = [] #list of those dictionaries
with open('stats4.txt') as data:
for line in data:
gameid = [item.strip('[') for item in line.split(']')]
del gameid[-1]
gameidstr = ''.join(gameid)
gameid = gameidstr
line = line[7:]
player, stats, outcome, date = [item.strip() for item in line.split('-', 3)]
stats = dict(zip(('kills', 'deaths', 'assists'), map(int, stats.split('/'))))
date = tuple(map(int, date.split('-')))
info[player] = dict(zip(('gameid', 'player', 'stats', 'outcome', 'date'), (gameid, player, stats, outcome, date)))
records.append(tuple((gameid, info[player]))) #add each dictionary of data to the records list



# just some testing code in this section below
print gameid
print player
print stats['kills']
print stats['deaths']
print stats['assists']
print outcome
print "This took place on %s/%s/%s" % (date[1], date[2], date[0])
print "\n\n", info, "\n\n"
champ = "Sona"
print info[champ].get('stats').get('kills'), "\n\n"
print "[%s] %s - %s/%s/%s - %s-%s-%s" % (info[champ].get('gameid'), champ, info[champ].get('stats').get('kills'), info[champ].get('stats').get('deaths'), info[champ].get('stats').get('assists'), info[champ].get('date')[0], info[champ].get('date')[1], info[champ].get('date')[2])
print "\n\n"
print info[champ].values()



#code to print records
i = 0

for item in records:
print "\n", "[%s] %s - %s/%s/%s - %s - %s-%s-%s" % (records[i][0], records[i][1]['player'], records[i][1]['stats']['kills'], records[i][1]['stats']['deaths'], records[i][1]['stats']['assists'], records[i][1]['outcome'], records[i][1]['date'][0], records[i][1]['date'][1], records[i][1]['date'][2])
i = i + 1

#my attempt at looping through the records list for a match
#def getstats(champion):
#p = 0
#x = champion
#matches = []
#try:
# while 1:
# p = x.index(value, p + 1)
# print "match at", p
#except ValueError:
# pass
print "\n"
#getstats(champ)
  1. import re
  2.  
  3. info = {} #dictionaries of game statistics
  4. records = [] #list of those dictionaries
  5. with open('stats4.txt') as data:
  6.         for line in data:
  7.                 gameid = [item.strip('[') for item in line.split(']')]
  8.                 del gameid[-1]
  9.                 gameidstr = ''.join(gameid)
  10.                 gameid = gameidstr
  11.                 line = line[7:]
  12.                 player, stats, outcome, date = [item.strip() for item in line.split('-', 3)]
  13.                 stats = dict(zip(('kills', 'deaths', 'assists'), map(int, stats.split('/'))))
  14.                 date = tuple(map(int, date.split('-')))
  15.                 info[player] = dict(zip(('gameid', 'player', 'stats', 'outcome', 'date'), (gameid, player, stats, outcome, date)))
  16.                 records.append(tuple((gameid, info[player]))) #add each dictionary of data to the records list
  17.  
  18.                
  19.                
  20. # just some testing code in this section below         
  21. print gameid
  22. print player
  23. print stats['kills']
  24. print stats['deaths']
  25. print stats['assists']
  26. print outcome
  27. print "This took place on %s/%s/%s" % (date[1], date[2], date[0])
  28. print "\n\n", info, "\n\n"
  29. champ = "Sona"
  30. print info[champ].get('stats').get('kills'), "\n\n"
  31. print "[%s] %s - %s/%s/%s - %s-%s-%s" % (info[champ].get('gameid'), champ, info[champ].get('stats').get('kills'), info[champ].get('stats').get('deaths'), info[champ].get('stats').get('assists'), info[champ].get('date')[0], info[champ].get('date')[1], info[champ].get('date')[2])
  32. print "\n\n"
  33. print info[champ].values()
  34.  
  35.  
  36.  
  37. #code to print records
  38. i = 0
  39.  
  40. for item in records:
  41.         print "\n", "[%s] %s - %s/%s/%s - %s - %s-%s-%s" % (records[i][0], records[i][1]['player'], records[i][1]['stats']['kills'], records[i][1]['stats']['deaths'], records[i][1]['stats']['assists'], records[i][1]['outcome'], records[i][1]['date'][0], records[i][1]['date'][1], records[i][1]['date'][2])
  42.         i = i + 1
  43.  
  44. #my attempt at looping through the records list for a match
  45. #def getstats(champion):
  46.         #p = 0
  47.         #x = champion
  48.         #matches = []
  49.         #try:
  50.         #       while 1:
  51.         #               p = x.index(value, p + 1)
  52.         #               print "match at", p
  53.         #except ValueError:
  54.         #       pass
  55. print "\n"
  56. #getstats(champ)
  57.  
go to heaven