title: Creating a dictionary from CSV using python
body: <p>I have a CSV of the format</p>
  
  <p><a href="https://i.stack.imgur.com/KqVTq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KqVTq.jpg" alt="enter image description here"></a></p>
  
  <p>where A, B &amp; C are the headers.</p>
  
  <p>How do I pythonically convert this CSV into a dictionary of the following form</p>
  
  <pre><code>{'A': '1', 'B': '4','C': '7'},
  {'A': '2', 'B': '5','C': '8'},
  {'A': '3', 'B': '6','C': '9'}
  </code></pre>
  
  <p>So far I'm trying the following code:</p>
  
  <pre><code>import csv
  reader = csv.DictReader(open('file.csv'))
  
  result = {}
  for row in reader:
      for column, value in row.items():
          result.setdefault(column, []).append(value)
  </code></pre>
  
  <p>This is not giving me the intended output. Any suggestions?</p>