title: Awk conditional sum from a CSV file
body: <p>I have a CSV file from which I would like to extract some pieces of information: for each distinct value in one colum, I would like to compute the sum of the corresponding values in another column. Eventually, I may do it in Python, but I believe there could be a simple solution using <code>awk</code>.</p>
  
  <p>This could be the CSV file:</p>
  
  <pre><code>2    1:2010-1-bla:bla    1.6
  2    2:2010-1-bla:bla   1.1
  2    2:2010-1-bla:bla    3.4
  2    3:2010-1-bla:bla    -1.3
  2    3:2010-1-bla:bla    6.0
  2    3:2010-1-bla:bla    1.1
  2    4:2010-1-bla:bla    -1.0
  2    5:2010-1-bla:bla    10.9
  </code></pre>
  
  <p>I would like to get:</p>
  
  <pre><code>1    1.6
  2    4.5
  3    5.8
  4    -1.0
  5    10.9
  </code></pre>
  
  <hr>
  
  <p>For now, I can only extract:</p>
  
  <p><strong>a) the values of the first colum:</strong></p>
  
  <pre><code>awk -F ' ' '{print $(2)}' MyFile.csv | awk -F ':' '{print $(1)}'
  </code></pre>
  
  <p>and then get:</p>
  
  <pre><code>1
  2
  2
  3
  3
  3
  4
  5
  </code></pre>
  
  <p><strong>b) and the values equal to, say, <code>1.1</code> in the last column with:</strong></p>
  
  <p><code>awk -F '    ' '{print $(NF)}' MyFile.csv | awk '$1 == 1.1'</code></p>
  
  <p>and then get:</p>
  
  <pre><code>1.1
  1.1
  </code></pre>
  
  <p>I am not able to simultaneously extract the columns I am interested in, which may help me in the end. Here is a sample output which may ease the computation of the sums (I don't know):</p>
  
  <pre><code>1    1.6
  2    1.1
  2    3.4
  3    -1.3
  3    6.0
  3    1.1
  4    -1.0
  5    10.9
  </code></pre>
  
  <p>Edit: Thanks to Elenaher, we could say the input is the file above.</p>