private static List<Point> GetCsvData(string filename)
{
var rval = new List<Point> { };
string[] lines = File.ReadAllLines(filename);
for (int i = 0; i < lines.Length; i++)
{
string[] line = lines[i].Split(',');
DateTime dt;
if (!DateTime.TryParse(line[0], out dt))
{
Console.WriteLine("error parsing date at row: " + (i + 1));
return new List<Point> { };
}
double val;
if (!double.TryParse(line[1], out val))
{
Console.WriteLine("error parsing value at row: " + (i + 1));
return new List<Point> { };
}
if (val < 0)
{
Console.WriteLine("error: data contains negative values that" +
" are incompatible with fitting of log normal distribution");
return new List<Point> { };
}
Point pt = new Point(dt, val);
rval.Add(pt);
}
return rval;
}