private static List<Point> GetVicData(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(new char[0],
StringSplitOptions.RemoveEmptyEntries);
DateTime dt = default(DateTime);
string value = string.Empty;
if (line.Length == 3)
{
dt = new DateTime(Convert.ToInt32(line[0]), Convert.ToInt32(line[1]), 1);
value = line[2];
}
else if (line.Length == 4)
{
dt = new DateTime(Convert.ToInt32(line[0]), Convert.ToInt32(line[1]),
Convert.ToInt32(line[2]));
value = line[3];
}
else
{
Console.WriteLine("unsupported input file format - " + filename);
return new List<Point> { };
}
double val;
if (!double.TryParse(value, 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;
}