Created
          May 21, 2022 14:16 
        
      - 
      
- 
        Save sly01/53830ca2d3f865b96b3aa64dfc11d20b to your computer and use it in GitHub Desktop. 
Revisions
- 
        sly01 created this gist May 21, 2022 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import re f = open("data.csv", "r") lines = f.readlines() regex = '\[(.*?)\] "(.*?)" (\d+) (\d+)' l = [] for line in lines: path = re.match(regex, line).group(2) status_code = re.match(regex, line).group(3) size =re.match(regex, line).group(4) d = {'path': path, 'status_code': status_code, 'size': size} l.append(d) l_get_200 = [x for x in l if x['status_code'] == '200' and 'GET' in x['path']] data = {} for i in l_get_200: n = i.get('path').split()[1] if n not in data: data[n] = int(i.get('size')) else: data[n] += int(i.get('size')) for k,v in sorted(data.items(), key=lambda x: x[1]): print(k,v)