Created
September 27, 2018 14:14
-
-
Save norbinsh/734c0892934780b3e0c12c727c9b1e30 to your computer and use it in GitHub Desktop.
This file contains 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 characters
import re | |
import json | |
regex_pattern = r"^logzero_default - (\d{4}-\d\d-\d\d).*INFO: ([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+), \d*. (.*).zip$" | |
input_file = 'logfile.log' | |
def return_rows(input_file): | |
with open(input_file, 'r') as inputf: | |
return inputf.read().splitlines() | |
data_list = [re.split(regex_pattern, row) for row in return_rows(input_file)] | |
versions_set = list(set(version[3] for version in data_list)) | |
data_dict = {ver: {date: list() for date in (set(date[1] for date in data_list))} for ver in versions_set} | |
for row in data_list: | |
data_dict[row[3]][row[1]].append(row[2]) | |
with open("data.json", "w") as json_file: | |
json.dump(data_dict, json_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment