title: Converting text file to dictionary in python
body: <p>So lets say I want to convert the following to a dictionary where the 1st column is keys, and 2nd column is values.</p>
  
  <p><a href="http://pastebin.com/29bXkYhd" rel="nofollow">http://pastebin.com/29bXkYhd</a></p>
  
  <p>The following code works for this (assume romEdges.txt is the name of the file):</p>
  
  <pre><code>f = open('romEdges.txt')
  
  dic = {}
  
  for l in f:
  
      k, v = l.split()
  
      if k in dic:
  
          dic[k].extend(v)
  
      else:
  
          dic[k] = [v]
  
  f.close()
  </code></pre>
  
  <p>OK</p>
  
  <p>But why doesn't the code work for this file?</p>
  
  <p><a href="http://pastebin.com/Za0McsAM" rel="nofollow">http://pastebin.com/Za0McsAM</a></p>
  
  <p>If anyone can tell me the correct code for the 2nd text file to work as well I would appreciate it.</p>
  
  <p>Thanks in advance.</p>