-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.py
107 lines (84 loc) · 3.31 KB
/
parse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/python
# To run, you will need to install python3 as well as pandas.
# you can install pandas with pip (or pip3) with the following
# command: ` python -m pip install pandas `
import os
import numpy as np
import pandas as pd
import csv
import argparse
parser = argparse.ArgumentParser(description="Winterspring Ski Team Bonus EP Calculator!", formatter_class=argparse.RawTextHelpFormatter)
def dir_path(path):
if os.path.isfile(path):
return path
else:
raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path")
parser.add_argument("-path", type=dir_path, help="The path to the WoWCombatLog.txt file to be parsed. Careful, these files can be pretty big! If you don't know where this is, its probably near where you put your addons folder like C:\\\Program Files\\World Of Wacraft\\_classic_\\Logs\\WowCombatLogs.txt")
args = vars(parser.parse_args())
# The assumption here is that if you went to get
# the DMT buffs, you got the HP buff and that counts
# as one world buff slot
world_buffs = [
"Rallying Cry of the Dragonslayer",
#"Fengus\' Ferocity",
"Spirit of Zandalar",
"Mol\'dar\'s Moxie",
"Songflower Serenade",
#"Slip\'kik\'s Savvy",
"Warchief\'s Blessing",
]
# If there are other consumables missing, add them to the list
# surrounded with double quotes. If there is an apostrophe, as
# in "Mol'dar's Moxie" you will need to put a backslash before each
# occurance as so: "Mol\'dar\'s Moxie",
consumables = [
"Spirit of Zanza",
"Greater Armor",
"Greater Stoneshield",
"Greater Arcane Elixir",
"Winterfall Firewater",
"Elixir of the Mongoose",
"Elixir of the Giants",
"Greater Agility",
"Flask of the Titans",
"Flask of Supreme Power",
"Flask of Distilled Wisdom"
"Greater Nature Protection Potion",
"Nature Protection Potion",
"Greater Fire Protection Potion"
]
with open (args['path']) as infile:
reader = csv.reader(infile)
title = next(reader)
headers = next(reader)
header_indices = [i for i, item in enumerate(headers) if item]
df = pd.read_csv(args['path'], usecols=[6, 10], skiprows=[0,1])
hero_consumables = {}
hero_world_buffs = {}
# iterate over the dataframes and check if the the buff is something
# of interest, if it is, mark who has the buff by adding it map of
# char_name -> { set of buffs }
#
# For consumes we make a different map of
# char_name => { buff_name -> count }
#
# This produces information about how many of a certain type of consume
# were used and not just which ones were used
for index, row in df.iterrows():
if(row[1] in consumables):
if (row[0] not in hero_consumables):
hero_consumables[row[0]] = {}
if row[1] not in hero_consumables[row[0]]:
hero_consumables[row[0]][row[1]] = 0
hero_consumables[row[0]][row[1]] += 1
elif (row[1] in world_buffs):
if (row[0] not in hero_world_buffs):
hero_world_buffs[row[0]] = {}
if row[1] not in hero_world_buffs[row[0]]:
hero_world_buffs[row[0]][row[1]] = True
world_buffs_out = pd.DataFrame(hero_world_buffs)
world_buffs_t = world_buffs_out.T
world_buffs_t.to_csv('wbuffs.csv')
consumes_out = pd.DataFrame(hero_consumables)
consumes_t = consumes_out.T
consumes_t.to_csv('consumes.csv')