title: Looping through columns in a .csv files in Python
body: <p>I want to be able to use Python to open a <code>.csv</code> file like this:</p>
  
  <pre><code>5,26,42,2,1,6,6
  </code></pre>
  
  <p>and then perform some operation on them like addition. </p>
  
  <pre><code>total = 0
  with open("file.csv") as csv_file:
          for row in csv.reader(csv_file, delimiter=','):
              for number in range(7):
                  total += int(row[number]) 
  </code></pre>
  
  <p>The problem is that since the <code>.csv</code> file only has one row and an unknown number of columns, I don't know how to make this work without either hard-coding it like or using really ugly code.</p>
  
  <p>Is there any way of looping through the columns using something like <code>for columns in file</code> in Python?</p>