private bool ReadEmissionData(bool readFC,
string DataPath,
string emissionClass,
Helpers Helper,
out List<string> header,
out List<List<double>> matrix,
out List<double> idlingValues)
{
// declare file stream
string line;
header = new List<string>();
matrix = new List<List<double>>();
idlingValues = new List<double>();
string pollutantExtension = "";
if (readFC)
pollutantExtension += "_FC";
string path = DataPath + @"\" + emissionClass + pollutantExtension + ".csv";
if (!File.Exists(path))
{
Helper.ErrMsg = "File do not exist! (" + path + ")";
return false;
}
StreamReader fileReader = File.OpenText(@path);
// read header line for pollutant identifiers
if ((line = ReadLine(fileReader)) != null)
{
List<string> entries = split(line, ',');
// skip first entry "Pe"
for (int i = 1; i < entries.Count; i++)
{
header.Add(entries[i]);
}
}
// skip units
ReadLine(fileReader);
// skip comment
ReadLine(fileReader);
//readIdlingValues
line = ReadLine(fileReader);
List<string> stringIdlings = split(line, ',').ToList();
stringIdlings.RemoveAt(0);
idlingValues = todoubleList(stringIdlings);
while ((line = ReadLine(fileReader)) != null)
{
matrix.Add(todoubleList(split(line, ',')));
}
fileReader.Close();
return true;
}
#endregion