I am trying to create a dictionary from a csv file. The first column of the csv file contains unique keys and the second column contains values. Each row of the csv file rep
You have to just convert csv.reader to dict:
~ >> cat > 1.csv key1, value1 key2, value2 key2, value22 key3, value3 ~ >> cat > d.py import csv with open('1.csv') as f: d = dict(filter(None, csv.reader(f))) print(d) ~ >> python d.py {'key3': ' value3', 'key2': ' value22', 'key1': ' value1'}