Ernie All American 45943 Posts user info edit post |
So I have a script that opens and reads a csv file. I'm trying to take what I get from the csv file, do some math, and store the updated values in a dictionary; only I can't get that last step to work.
import csv
d = {}
reader = csv.reader(open('file.csv', 'rb')) for row in reader: name = row[0] date = row[1] x = row[2] y = row[3] z = x + y
The dictionary I'd like to store the values in would look like:
d = { 'Jim': [ {'2008-04-19':17}, {'2008-04-17':15} ], 'Bob': [ {'2008-02-11':18}, {'2008-01-12':22} ] }
It seems like I couldn't use d.update() because that would just overwrite whatever is already in d. And there isn't an append() function for dictionaries, which I would think would make this a lot easier. So, help me.
[Edited on April 19, 2008 at 1:06 PM. Reason : ]4/19/2008 12:59:52 PM |