title: Convert a csv to a dictionary with multiple values?
body: <p>I have a csv file like this:</p>
  
  <pre><code>pos,place
  6696,266835
  6698,266835
  938,176299
  940,176299
  941,176299
  947,176299
  948,176299
  949,176299
  950,176299
  951,176299
  770,272944
  2751,190650
  2752,190650
  2753,190650
  </code></pre>
  
  <p>I want to convert it to a dictionary like the following:</p>
  
  <pre><code>{266835:[6696,6698],176299:[938,940,941,947,948,949,950,951],190650:[2751,2752,2753]}
  </code></pre>
  
  <p>And then, fill the missing numbers in the range in the values:</p>
  
  <pre><code>{{266835:[6696,6697,6698],176299:[938,939,940,941,942,943,944,945,946947,948,949,950,951],190650:[2751,2752,2753]}
  }
  </code></pre>
  
  <p>Right now i have tried to build the dictionary using solution suggested <a href="https://stackoverflow.com/questions/11831216/convert-selected-columns-in-csv-to-dictionary">here</a>, but it overwrites the old value with new one.</p>
  
  <p>Any help would be great.</p>
  
  <p>Here is a function that i wrote for converting csv2dict</p>
  
  <pre><code>def csv2dict(filename):
  """
  reads in a two column csv file, and the converts it into dictionary
  """
  import csv
  with open(filename) as f:
      f.readline()#ignore first line
      reader=csv.reader(f,delimiter=',')
      mydict=dict((rows[1],rows[0]) for rows in reader)
  return mydict   
  </code></pre>