How to associate lists with keys and values to create a dictionary in Python?
Is the problem the following? I have a large csv file and I need to read the first line (make it into a list) that should be used to bind to the Keys and the following lines should be the values.
One option I imagined would be to use for loops to read each item in the lists and do the assignment. But do not you have a function / method that does this?
Here is a snippet of the code, considering only the keys and the first line (values).
The next step is to build a list of dictionaries, each for each line; but I think I know how to do it.
f = open("beatles-diskography.csv", "r")
hd = f.readline()
fl = f.readline()
hd = hd.split(',')
fl = fl.split(',')
c = 0
for s in hd:
s = s.strip()
hd[c] = s
c = c+1
c = 0
for s in fl:
s = s.strip()
fl[c] = s
c = c+1
'''
dic = ???
'''