I have a csv file in the following format:
age,name
3,abc
5,xyz
6,pqr
4,stu
8,lkm
How can I put this in a dictionary in the following format:
{3:'abc', 5:'xyz', 6:'pqr', 4:'stu', 8:'lkm'}
UPDATE:
mycode-
age_file = open('age.csv','r')
csv_age = csv.DictReader(age_file)
for row in csv_age:
print(row)
OUTPUT:
{'age' : 3, 'name' : 'abc', 'age' : 5, 'name' : xyz, ... }