I have a.csv file as below:
 OLD,NEW
 AA,XX
 BB,YY
 CC,ZZ
I wanna convert it to dict format, say dict1 = {'AA':'XX','BB':'YY','CC':'ZZ'} Should I use DictReader or join string?
with open('file.csv') as f:
    f.readline() # ignore first line (header)
    mydict = dict(csv.reader(f, delimiter=','))
print mydict
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With