title: Calculating the average of a column in a CSV file using linq c#
body: <p>I am really new to c# but I really want to start using linq to extract simple information from excel spreadsheets. </p>
  
  <p>I feel quite embarrassed to ask this, but I can't seem to find a solution. Basically, all I want is find the average of the amount of donations within a CSV file. </p>
  
  <p><img src="https://i.stack.imgur.com/oCgcu.png" alt="The Excel file layout"></p>
  
  <p>This is following code so far:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace CSharpTest
  {
      class Program
  {
      public string Donor { get; set; }
      public DateTime Date { get; set; }
      public decimal Amount { get; set; }
      public string Charity { get; set; }
  
      static void Main(string[] args)
      {
          {
  
              var file = "C:\\Users\\user\\Desktop\\Donations.csv".AsFile();
  
              File.ReadAllLines(file).Select(x =&gt; x.Split('\n')).Average(x =&gt; x.Count());
  
  
          }
  
      }
  }
  </code></pre>
  
  <p>The thing is I know this is wrong as I only want the values in Amount. For something like this I am sure I should be using GroupBy(), however I can't seem to extract the public class Amount. I would be ever so grateful if someone could point me in the right direction please. Many thanks.</p>