title: Python: calculate the sum of a column after splitting the column
body: <p>I'm new at writing python and thought I would re-write some of my programs that are in perl.
  I have a tab delimited file, where columns 9-through the end (which varies) needs to be further split and then the sum of part of that column added</p>
  
  <p>for instance, input (only looking at columns 9-12):</p>
  
  <pre><code>0:0:1:0    0:0:2:0    0:0:3:0    0:0:4:0
  0:0:1:0    0:0:2:0    0:0:3:0    0:0:4:0
  0:0:1:0    0:0:2:0    0:0:3:0    0:0:4:0
  0:0:1:0    0:0:2:0    0:0:3:0    0:0:4:0
  </code></pre>
  
  <p>output (sum of each column[2]:</p>
  
  <pre><code>4
  8
  12
  16
  </code></pre>
  
  <p>All I've got so far is</p>
  
  <pre><code>        datacol = line.rstrip("\n").split("\t")
          for element in datacol[9:len(datacol)]:
              splitcol=int(element.split(r":")[2])
              totalcol += splitcol
          print(totalcol)
  </code></pre>
  
  <p>which doesn't work and gives me the sum of column[2] for each row.</p>
  
  <p>Thanks</p>