Question: how to convert a csv file to a dictionary in python?
Answer: import csv.
import sys. ... 
# Function to convert a csv file to a list of dictionaries. ... 
def csv_dict_list(variables_file):
# Open variable-based csv, iterate over the rows and map values to a list of dictionaries containing key/value pairs.
reader = csv.DictReader( open (variables_file, 'rb' ))
dict_list = []