title: Python reading in integers from a csv file into a list
body: <p><a href="https://i.stack.imgur.com/8xBro.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8xBro.png" alt="enter image description here"></a>I am having some trouble trying to read a particular column in a csv file into a list in Python. Below is an example of my csv file:</p>
  
  <pre><code>Col 1       Col 2
  1,000,000   1
    500,000   2
    250,000   3
  </code></pre>
  
  <p>Basically I am wanting to add column 1 into a list as integer values and am having a lot of trouble doing so. I have tried:</p>
  
  <pre><code>for row in csv.reader(csvfile):
      list = [int(row.split(',')[0]) for row in csvfile]
  </code></pre>
  
  <p>However, I get a ValueError that says "invalid literal for int() with base 10: '"1'</p>
  
  <p>I then tried:</p>
  
  <pre><code>for row in csv.reader(csvfile):
      list = [(row.split(',')[0]) for row in csvfile]
  </code></pre>
  
  <p>This time I don't get an error however, I  get the list:</p>
  
  <pre><code>['"1', '"500', '"250']
  </code></pre>
  
  <p>I have also tried changing the delimiter:</p>
  
  <pre><code>for row in csv.reader(csvfile):
      list = [(row.split(' ')[0]) for row in csvfile]
  </code></pre>
  
  <p>This almost gives me the desired list however, the list includes the second column as well as, "\n" after each value:</p>
  
  <pre><code>['"1,000,000", 1\n', etc...]
  </code></pre>
  
  <p>If anyone could help me fix this it would be greatly appreciated!</p>
  
  <p>Cheers</p>