title: How to average column data for multiple columns in text files?
body: <p>I have a tab delimited data text file in the following format:</p>
  
  <pre><code>Depth    Temp    Salinity
  0.30    28.30    31.90
  0.30    28.30    31.90
  0.30    28.20    31.90
  0.30    28.20    31.90
  0.40    28.20    32.00
  0.40    28.00    32.00
  0.50    28.00    31.90
  0.60    28.00    32.00
  0.70    27.90    32.00
  0.60    27.90    32.10
  </code></pre>
  
  <p>What I want to achieve is to obtain any lines where there are duplicate values in the Depth column and put them into a list/s. Then from that list/s I will average these values for each column (not averaging the Depth column), sort the values by Depth, and then output all this back into the original data file format. So in the example file above, the output would be:</p>
  
  <pre><code>Depth    Temp    Salinity
  0.30    28.25    31.90
  0.40    28.10    32.00
  0.50    28.00    31.90
  0.60    27.95    32.05
  0.70    27.90    32.00
  </code></pre>
  
  <p>I understand I need to use .readlines() to grab the relevant lines, but how do I only grab duplicate lines?</p>
  
  <p>Thanks in advance!</p>