title: read text file lines and create a dictionary using python
body: <p>I have a following text file format  </p>
  
  <pre><code>Id,    person, age,  city
  ef12,  james,  23,   berlin  
  yt34,  mary,   45,   pisa  
  rt23,  john,   56,   barcelona
  </code></pre>
  
  <p>I want to generate a dictionary of below kind. Please help me out .</p>
  
  <pre><code>{ef12: {person:'james', age:'23',city:'berlin'},   
  yt34: {person:'mary', age:'45',city:'pisa'},    
  rt23: {person:'john', age:'23',city:'barcelona'},  
  
  }
  </code></pre>
  
  <p>I am stuck at below </p>
  
  <pre><code>`import time
  import sys
  
  def getData():
      file = open('traffic.txt', 'r')
      data = file.readlines()
      myDic = {}
      #for line in data.split('\n'):
      for line in data:
          tmp = line.strip().split()
          #myDic[tmp[0]]= list(tmp[1])
          #print(tmp[2])
          myDic[tmp[0]] = {tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]}
      file.close()
      return myDic
  theNewDictionary = getData()
  print(theNewDictionary)
  `
  </code></pre>