Skip to content

Instantly share code, notes, and snippets.

@momorientes
Last active August 29, 2015 14:19
Show Gist options
  • Save momorientes/56329018655de8f88db3 to your computer and use it in GitHub Desktop.
Save momorientes/56329018655de8f88db3 to your computer and use it in GitHub Desktop.
#!/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