hi!
i want to place the contents of a dictionary into a csv file. Can someone help me with this?
i already have the code in reading the csv file
import csv
reader = csv.reader(open("c:\sample.dat"))
for row in reader:
print row
i want the first element of the row be the key for the dictionary so that if i access the dictionary again using the key i'll be able to get the different of the rows of that dictionary. I just don't know how to use loop thru the csv rows and put it in the dictionary and use the first element as a key.
for example: key name is key:
//key as the key
key == first element of the row.
d = {'key': [1,2,3,4,5,6]}
//accessing the dictionary using key and were able to get the other elements of the row
d [1, 2, 3, 4, 5, 6]
can someone help me code this.
Thanks!