Skip to content

Instantly share code, notes, and snippets.

@witcheslive
Created December 12, 2023 00:39
Show Gist options
  • Save witcheslive/ad22a44f3113162cf9b48ade19067e12 to your computer and use it in GitHub Desktop.
Save witcheslive/ad22a44f3113162cf9b48ade19067e12 to your computer and use it in GitHub Desktop.
hxi clamming log parser version 1.0
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