private static List <FetchedData> ReadAndUnifyData(string dataPath, out List <string> columns) { columns = new List <string>(); List <FetchedData> rawData = new List <FetchedData>(); const int valueStartIndex = 1; const int dateIndex = 0; using (StreamReader reader = new StreamReader(dataPath)) { // Read columns header string line = reader.ReadLine(); string[] dataColumns = line.Split(';'); for (int i = valueStartIndex; i < dataColumns.Length; i++) { columns.Add(dataColumns[i]); } line = reader.ReadLine(); while (!string.IsNullOrEmpty(line)) { try { var values = line.Split(';'); DateTime timeStamp = DateTime.Parse(values[dateIndex]); var fetchedData = new FetchedData { TimeStamp = timeStamp }; fetchedData.Values = new List <double>(values.Length - 1); for (var i = valueStartIndex; i < values.Length; i++) { fetchedData.Values.Add(double.Parse(values[i])); } rawData.Add(fetchedData); } catch (ArgumentException) { } line = reader.ReadLine(); } reader.Close(); } return(new List <FetchedData>(rawData)); }
public static FetchedData[] FetchArrayGen(int numGenerate) { if (numGenerate < 0) { return null; } if (numGenerate == 0) { return new FetchedData[0]; } if (numGenerate == 1) { return new[] {new FetchedData("A")}; } var fetched = new FetchedData[numGenerate]; for (var i = 0; i < numGenerate; i++) { var c = 'A' + i; fetched[i] = new FetchedData(char.ToString((char) c)); } return fetched; }
public static FetchedData[] FetchArrayGen(int numGenerate) { if (numGenerate < 0) { return(null); } if (numGenerate == 0) { return(new FetchedData[0]); } if (numGenerate == 1) { return(new FetchedData[] { new FetchedData("A") }); } var fetched = new FetchedData[numGenerate]; for (var i = 0; i < numGenerate; i++) { var c = 'A' + i; fetched[i] = new FetchedData(((char)c).ToString(CultureInfo.InvariantCulture)); } return(fetched); }