1- import pandas as pd
1+ from datetime import datetime
2+ from objects .match import Match
23
34
45class LogAnalyser :
56
6- def __init__ (self , path_csv ) -> None :
7+ def __init__ (self , path_csv , name ) -> None :
78
89 self .path_csv = path_csv
10+ self .name = "Log-2023-12-22-21-12-32.txt"
911
10-
12+ self .date = self .name2datetime ()
13+
14+ self .match = None
15+
16+ self .actions = {"match_start" : self .process_match_start ,
17+ "round_start" : self .process_round_start ,
18+ "hero_spawn" : self .process_hero_spawn }
1119
1220 def run (self ):
1321
1422 with open (self .path_csv , encoding = 'utf-8' ) as my_file :
1523 line = my_file .read ()
1624 line_split = line .split ("," )
17- print (line_split )
25+ # print(line_split)
1826
1927 timestamp = line_split [0 ]
2028 type = line_split [1 ]
29+
30+ if type in self .actions :
31+ self .actions [type ](line_split )
32+
2133
34+ def name2datetime (self ):
35+
36+ date_string = self .name .split ("." )[0 ].split ("Log-" )[1 ]
37+ date_object = datetime .strptime (date_string , '%Y-%m-%d-%H-%M-%S' )
38+
39+ return date_object
40+
2241
2342 def process_kill (self ):
2443 pass
@@ -28,13 +47,26 @@ def process_ultimate_charged(self):
2847 pass
2948
3049 def process_round_start (self ):
31- pass
50+
51+ self .match .add_round ()
3252
3353 def process_round_stop (self ):
3454 pass
3555
36- def process_match_start (self ):
56+ def process_match_start (self , data ):
57+
58+ self .match = Match .from_json ({"rounds" : [],
59+ "date" : self .date ,
60+ "map_name" : data [3 ],
61+ "map_type" : data [4 ],
62+ "team1_name" : data [5 ],
63+ "team2_name" : data [6 ]
64+ })
65+
66+ def process_hero_spawn (self , data ):
3767 pass
68+
69+
3870
39- la = LogAnalyser ('src/logs/Log-2023-12-22-21-12-32.txt' )
71+ la = LogAnalyser ('src/logs/Log-2023-12-22-21-12-32.txt' , "Log-2023-12-22-21-12-32.txt" )
4072la .run ()
0 commit comments