Created
December 12, 2023 00:39
-
-
Save witcheslive/ad22a44f3113162cf9b48ade19067e12 to your computer and use it in GitHub Desktop.
hxi clamming log parser version 1.0
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 json | |
import os | |
data = [] | |
order = ["date", "item"] | |
counter = {} | |
for filename in os.listdir(os.getcwd()): | |
with open(os.path.join(os.getcwd(), filename), 'r') as file: # open in readonly mode | |
for line in file.readlines(): | |
details = line.split(", ") | |
details = [x.strip() for x in details] | |
structure = {key: value for key, value in zip(order, details)} | |
data.append(structure) | |
for datum in data: | |
if datum['item'] not in counter: | |
counter[datum['item']] = 0 | |
counter[datum['item']] += 1 | |
total = 0 | |
for item in counter: | |
print(item + ": " + str(counter[item])) | |
total += counter[item] | |
print("\nTotal items: " + str(total)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment