title: C# take a duplicate entry in a CSV file and remove the duplicate by taking an average
body: <p>My program creates a .csv file with a persons name and an integer next to them.</p>
  
  <p>Occasionally there are two entries of the same name in the file, but with a different time. I only want one instance of each person.</p>
  
  <p>I would like to take the mean of the two numbers to produce just one row for the name, where the number will be the average of the two existing.</p>
  
  <p><img src="https://i.stack.imgur.com/4YMfq.png" alt="This is my csv file"></p>
  
  <p>So here Alex Pitt has two numbers. How can I take the mean of 105 and 71 (in this case) to produce a row that just includes Alex Pitt, 88?</p>
  
  <p>Here is how I am creating my CSV file if reference is required.</p>
  
  <pre><code>public void CreateCsvFile()
      {
          PaceCalculator ListGather = new PaceCalculator();
          List&lt;string&gt; NList = ListGather.NameGain();
          List&lt;int&gt; PList = ListGather.PaceGain();
  
          List&lt;string&gt; nAndPList = NList.Zip(PList, (a, b) =&gt; a + ", " + b).ToList();
  
          string filepath = @"F:\A2 Computing\C# Programming Project\ScheduleFile.csv";
  
          using (var file = File.CreateText(filepath))
          {
              foreach (var arr in nAndPList)
              {
                  if (arr == null || arr.Length == 0) continue;
                  file.Write(arr[0]);
                  for (int i = 1; i &lt; arr.Length; i++)
                  {
                      file.Write(arr[i]);
                  }
                  file.WriteLine();
              }
          }
      }
  </code></pre>