title: How to convert CSV file into a list of dictionaries in python
body: <p>I have a csv file that looks like the following:</p>
  
  <p><a href="https://i.stack.imgur.com/ORkBY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ORkBY.png" alt="enter image description here"></a></p>
  
  <p>I need to convert this into a list of dictionaries that looks like the following:</p>
  
  <pre><code>users = [{ "id": 0, "name": "James" },
  { "id": 1, "name": "John" },
  { "id": 2, "name": "Jake" },
  { "id": 3, "name": "Jim" },
  { "id": 4, "name": "Alex" },
  { "id": 5, "name": "Adam" },
  { "id": 6, "name": "Ryan" },
  { "id": 7, "name": "Katie" },
  { "id": 8, "name": "Julia" },
  { "id": 9, "name": "Sam" }]
  </code></pre>
  
  <p>I also have this CSV file of "connections" between each user based on their ids:</p>
  
  <p><a href="https://i.stack.imgur.com/76Pp8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/76Pp8.png" alt="enter image description here"></a></p>
  
  <p>I have been trying for hours to get this to just be a simple list of tuples that look like the following:</p>
  
  <pre><code>friends = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)]
  </code></pre>
  
  <p>I have tried every way of importing csv files I know, but I've never dealt with one that wants me to make a new dictionary for every entry, and i dont think ive ever dealt with one without headers like this. While I wish I could just add headers and my my life easier, it must look like the example I gave above for the rest of my code to work. Please let me know if you have any idea how to do this. Thank you!</p>
  
  <p>I completed this entire project of mine, but had to hardcode the mentioned dictionary and list because I simply do not know how to handle having no headers in a CSV and making them look like this. Any help would be greatly appreciated!</p>