public static List <InputTable> ReadInputTableData(string dataPath) //takes inputs ^^ and writes to file { var inputList = new List <InputTable>(); var fs = new FileStream(dataPath, FileMode.Open); var sr = new StreamReader(fs); var isHeader = false; int counter = 0; string line; while (sr.Peek() != -1) { var inputRow = new InputTable(); line = sr.ReadLine(); if (!isHeader) { isHeader = !isHeader; continue; } var dataElements = line.Split(','); inputRow.s = Utility.ConvertToBoolean(dataElements[0]); inputRow.r = Utility.ConvertToBoolean(dataElements[1]); inputRow.q = Utility.ConvertToBoolean(dataElements[2]); inputRow.n = Utility.ConvertToBoolean(dataElements[3]); inputList.Add(inputRow); //System.Console.WriteLine(line); System.Console.WriteLine(line); counter++; } System.Console.ReadLine(); sr.Close(); fs.Close(); return(inputList); }
public static bool SaveInputTableData(InputTable tt) { return(SaveInputTableData( tt.s ? 1 : 0, tt.r ? 1 : 0, tt.q ? 1 : 0, tt.n ? 1 : 0 )); }
public static InputTable ReadInputTable() { var inputRow = new InputTable(); if (!File.Exists(STORAGE)) { return(inputRow); } var data = File.ReadAllText(STORAGE); var dataElements = data.Split(','); // 0,1,0,1 will be split into arrays inputRow.s = Utility.ConvertToBoolean(dataElements[0]); //converts split data to boolean inputRow.r = Utility.ConvertToBoolean(dataElements[1]); inputRow.q = Utility.ConvertToBoolean(dataElements[2]); inputRow.n = Utility.ConvertToBoolean(dataElements[3]); return(inputRow); //return inputRow; }