I am having a csv file like this
A, 22, 23, 12
B, 32, 4, 33
C, 34, 3 ,33
I want to print the sum and average of each row and skip the first
string csvFile = @"myfile.csv";
string[] lines = File.ReadAllLines(csvFile);
var values = lines.Select(l => new { FirstColumn = l.Split(',').First(), Values = l.Split(',').Skip(1).Select(v => int.Parse(v)) });
foreach (var value in values)
{
Console.WriteLine(string.Format("Column '{0}', Sum: {1}, Average {2}", value.FirstColumn, value.Values.Sum(), value.Values.Average()));
}