public void LoadFromFile(string filename) { // If already loaded, does nothing Console.WriteLine("Loading " + filename + "..."); if (filename == loaded) // FIXME { Console.WriteLine("Already loaded."); return; } var data = from line in EasyCSV.FromFile(filename) select new { Inputs = line.Slice(0, InputCount) .Select(x => double.Parse(x, System.Globalization.NumberFormatInfo.InvariantInfo)) .ToList() }; InputSamples = new List <List <double> >(); foreach (var entry in data) { InputSamples.Add(entry.Inputs); } Console.WriteLine("InputCount = " + InputCount); Console.WriteLine("data.Count = " + data.Count()); }
public void LoadFromFile(string filename) { // If already loaded, does nothing Console.WriteLine("Loading " + filename + "..."); if (filename == loaded) // FIXME { Console.WriteLine("Already loaded."); return; } int nbRowsPerMatrix; using (StreamReader rdr = new StreamReader(filename)) { nbRowsPerMatrix = int.Parse(rdr.ReadLine().Trim()); } int currentRowId = 0; // Parse the data var data = from line in EasyCSV.FromFile(filename).Skip(1) select new { Inputs = line.Select(x => parseToDouble(x)) .Concat(new double[] { currentRowId++ / nbRowsPerMatrix }) .ToList() }; InputSamples = new List <List <double> >(); foreach (var entry in data) { InputSamples.Add(entry.Inputs); } InputCount = currentRowId / nbRowsPerMatrix; RowCount = nbRowsPerMatrix; ColumnCount = data.First().Inputs.Count() - 1; Console.WriteLine("data.Count = " + data.Count()); Console.WriteLine("InputCount = " + InputCount); Console.WriteLine("RowCount = " + RowCount); Console.WriteLine("ColumnCount = " + ColumnCount); }