Answers for "convert csv columns to dictionary python"

0

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)
Posted by: Guest on August-20-2021

Code answers related to "convert csv columns to dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language