private static List <UCIData> ReadUCIData() { List <UCIData> UCIresult = new List <UCIData>(); var assembly = typeof(UCIData).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("HARApp.Assets.UCIDataset.csv"); StreamReader oSR = new StreamReader(stream); string sLine = oSR.ReadLine(); sLine = oSR.ReadLine(); while (sLine != null) { try { Debug.WriteLine(sLine); UCIData UCIdata = CreateUCIData(sLine); UCIresult.Add(UCIdata); } catch (Exception ex) { Debug.WriteLine("Error on line: " + sLine); } sLine = oSR.ReadLine(); } Debug.WriteLine("----------------------------------------------------------------------"); oSR.Close(); return(UCIresult); }
private static List <float> CreateRow(UCIData line) { List <float> UCIrow = new List <float>(); UCIrow.Add(line.acc_X); UCIrow.Add(line.acc_Y); UCIrow.Add(line.acc_Z); UCIrow.Add(line.acc_XY); UCIrow.Add(line.acc_XZ); UCIrow.Add(line.acc_YZ); UCIrow.Add(line.acc_XYZ); UCIrow.Add(line.gyro_X); UCIrow.Add(line.gyro_Y); UCIrow.Add(line.gyro_Z); return(UCIrow); }
private static UCIData CreateUCIData(string sLine) { UCIData UCIdata = new UCIData(); String[] parts = sLine.Split(','); UCIdata.acc_X = float.Parse(parts[0]); UCIdata.acc_Y = float.Parse(parts[1]); UCIdata.acc_Z = float.Parse(parts[2]); UCIdata.acc_XY = float.Parse(parts[0]) * float.Parse(parts[1]); UCIdata.acc_XZ = float.Parse(parts[0]) * float.Parse(parts[2]); UCIdata.acc_YZ = float.Parse(parts[1]) * float.Parse(parts[2]); UCIdata.acc_XYZ = float.Parse(parts[0]) * float.Parse(parts[1]) * float.Parse(parts[2]); UCIdata.gyro_X = float.Parse(parts[3]); UCIdata.gyro_Y = float.Parse(parts[4]); UCIdata.gyro_Z = float.Parse(parts[5]); UCIdata.Label = parts[6]; return(UCIdata); }