title: Create nested dictionary from text file using Python 3
body: <p>This is my file: test.txt</p>
  
  <pre><code>Amy|Female|Desc1|12
  John|Male|Desc2|10
  Mike|Male|Desc3|18
  </code></pre>
  
  <p>I tried to create nested dictionary and it's not sucessful.</p>
  
  <p>This is the output:</p>
  
  <pre><code>{'Amy': '12', 'John': '10', 'Mike': '18'}
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>import csv
  with open('test.txt') as file:
      tsvfile = csv.reader(file, delimiter='|')
      d = {}
  
      for row in tsvfile:
          d[row[0]] = row[0] #this should be name
          d[row[0]] = row[1] #this should be gender
          d[row[0]] = row[3] #this should be desc
          d[row[0]] = row[3] #this should be age
      print(d)
  </code></pre>
  
  <p>My desired output as below but was not successful.</p>
  
  <pre><code>d={1{'Name':'Amy', 'Gender':'Female', 'Desc': 'Desc1', 'Age': '12'}
   2{'Name':'John', 'Gender':'Male', 'Desc': 'Desc2', 'Age': '10'}
   3{'Name':'Mike', 'Gender':'Male', 'Desc': 'Desc3', 'Age': '18'}}
  </code></pre>
  
  <p>and below (with name and age only</p>
  
  <pre><code>d1={1{'Name':'Amy','Age': '12'}
   2{'Name':'John', 'Age': '10'}
   3{'Name':'Mike', 'Age': '18'}}
  </code></pre>