title: Importing csv as dictionary - none type error
body: <p>How can I import a .csv file as a dictionary?</p>
  
  <p>I'm trying to import a .csv file as a dictionary. The .csv file has two columns: a key called "AIRPORT CODE" and an element called "AIRPORT". I first try to import it as a list because I figured its easier to convert from a list to a dictionary.</p>
  
  <pre><code>def load_airports_dict(filename):
      import csv
  
      reader = csv.reader(open(filename, 'r'))
      data_list = []
  
      for row in reader:
          data_list.append(row)
  
      d = { }
  
      for row in data_list:
          d[row[0]] = row[1]
      print(d)
  </code></pre>
  
  <p>Unfortunately, when trying to call a function to slice the dictionary I get ''NoneType' object is not subscriptable' even though if I run the code outside of the function it gives me what I'm looking for. </p>