Created
June 15, 2018 02:28
-
-
Save hahastudio/d096995dc535abcad6046d79e238add4 to your computer and use it in GitHub Desktop.
gist for https://www.v2ex.com/t/463296
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
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