Last active
August 29, 2015 14:19
-
-
Save momorientes/56329018655de8f88db3 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
#!/usr/bin/env python3 | |
data = {} | |
def main(): | |
FILENAME = 'foo.csv' | |
with open(FILENAME, 'r') as f: | |
for line in f.readlines(): | |
line = line.strip() | |
line = line.split(',') | |
aggregate(line) | |
print(data) | |
def aggregate(line): | |
key = line[0] | |
value = line[1] | |
if key in data: | |
data[key] += value | |
else: | |
data[key] = value | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment