Skip to content

Instantly share code, notes, and snippets.

@hahastudio
Created June 15, 2018 02:28
Show Gist options
  • Save hahastudio/d096995dc535abcad6046d79e238add4 to your computer and use it in GitHub Desktop.
Save hahastudio/d096995dc535abcad6046d79e238add4 to your computer and use it in GitHub Desktop.
result = dict()
filepath = r"D:\test.log"
with open(filepath, "r") as fin:
for line in fin:
parts = line.split(", ")
tag = parts[0]
value = float(parts[1])
result.setdefault(tag, []).append(value)
for k, v in result.iteritems():
print k, sum(v), sum(v)/len(v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment