I have a csv that looks like:
Column1,Column2,Column3,Column4,Column5,Column6,Column7,Column7,Column8,Column9,
45.50334645,5640192,3915776,52633600,351924224,12354,90505216,78790656,247287808,
39.23091283,5640192,3915776,52633600,349986816,4562,90505216,78790656,247287808,
25.26042,5640192,3915776,52633600,349986816, ,90505216,78790656,247287808,
I need to get the MIN, MAX, and Average from each column. I am using LINQ to do this since the CSV's can be quite large.
Here is the current code I have.
var lines = System.IO.File.ReadAllLines(csvPath);
var columns = lines[0].Split(',');
for (int i = 1; i < columns.Count(); i++)
{
var columnQuery = from line in lines
let elements = line.Split(',')
select Convert.ToDouble(elements[i]);
var results = columnQuery.ToList();
var min = results.Min();
var max = results.Max();
var avg = results.Average();
}
This will error out on the highlighted value in the csv since it is considered a Datetime.
The error I get is "Input string was not in a correct format."
Thanks for any help.