Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Convert csv to dictionary in Python

 pythonCopyimport csv

mydict = {}

with open('csv_file.csv', mode='r') as inp:
    reader = csv.reader(inp)
    dict_from_csv = {rows[0]:rows[1] for rows in reader}

print(dict_from_csv)
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #Convert #csv #dictionary #Python
ADD COMMENT
Topic
Name
3+4 =