//path_data : row are selected, 2 columns to be cropped ("time,id") //path_minmax : minmax, no crop is needed, leave "" for local MM //path_folder & filename : path to save //Auto Crop Column Name public static void ChangeAnalysis(string path_data_selected, string path_GlobalMM, string path_folder, string filename) { try { path_PE_localMM = path_folder + @"\[MinMax(local)].csv";//in case Local path_PE_vRank = path_folder + @"\" + filename + " F-Rank.csv"; path_PE_normal_extract = path_folder + @"\" + filename + " Extracted-03 Normalized.csv"; DataTable dt_temp = CSVReader.ReadCSVFile(path_data_selected, true); //have 2 unused col DataTable dt_data = TheTool.dataTable_cropCol(dt_temp, 2, 0); //only analyzed column DataTable dt_mm = null; //Datatable of MinMax //--- Prepare MinMax Table Boolean useGlobalMM = true; if (path_GlobalMM == "" || File.Exists(path_GlobalMM) == false) { useGlobalMM = false; } else { try { dt_mm = CSVReader.ReadCSVFile(path_GlobalMM, true); } catch (Exception ex) { TheSys.showError(ex); useGlobalMM = false; } } if (useGlobalMM == false) { //build MM table by local data dt_mm = TheTool.dataTable_getMaxMinTable(dt_data);//generate MM table TheTool.export_dataTable_to_CSV(path_PE_localMM, dt_mm); } try { DataTable dt_normal = TheTool.dataTable_MinMaxNormalization(dt_data, dt_mm); //--- Cal Change ------------------------------------- List <String> data_raw_change = ThePosExtract.process_calChange(dt_data, false, false); List <String> data_normal_change = ThePosExtract.process_calChange(dt_normal, true, true); List <String> data_ChangeAnalysis = new List <String>(); data_ChangeAnalysis.Add("RAW"); data_ChangeAnalysis.AddRange(data_raw_change); data_ChangeAnalysis.Add(""); data_ChangeAnalysis.Add(""); data_ChangeAnalysis.Add("NORMALIZED F-RANKING"); data_ChangeAnalysis.AddRange(data_normal_change); TheTool.exportCSV_orTXT(path_PE_vRank, data_ChangeAnalysis, false); //--- Normalize Table : re-added column before save dt_normal.Columns.Add("time", typeof(string)).SetOrdinal(0); dt_normal.Columns.Add("id", typeof(string)).SetOrdinal(0); int r = 0; foreach (DataRow row in dt_normal.Rows) { row[0] = dt_temp.Rows[r][0].ToString(); row[1] = dt_temp.Rows[r][1].ToString(); r++; } TheTool.export_dataTable_to_CSV(path_PE_normal_extract, dt_normal); } catch (Exception ex) { TheSys.showError("Normalize: " + ex.ToString()); } } catch (Exception ex) { TheSys.showError("Change Analysis: " + ex.ToString()); } }
void readData(string fileName) { try { dataTable = CSVReader.ReadCSVFile(fileName, true); dataGrid.ItemsSource = dataTable.DefaultView; dataGrid.AutoGenerateColumns = true; dataGrid.IsReadOnly = true; txtRow.Content = "Row: " + dataTable.Rows.Count; calSplit(); } catch { } }
//Data contain "time,id" public static DataTable getNormalizedTable(string path_data_selected, string path_GlobalMM, Boolean Crop2Col) { try { DataTable dt_temp = CSVReader.ReadCSVFile(path_data_selected, true);//have 2 unused col DataTable dt_data = dt_temp; if (Crop2Col) { dt_data = TheTool.dataTable_cropCol(dt_temp, 2, 0); //only analyzed column } DataTable dt_mm = null; //Datatable of MinMax //--- Prepare MinMax Table Boolean useGlobalMM = true; if (path_GlobalMM == "" || File.Exists(path_GlobalMM) == false) { useGlobalMM = false; } else { try { dt_mm = CSVReader.ReadCSVFile(path_GlobalMM, true); } catch (Exception ex) { TheSys.showError(ex); useGlobalMM = false; } } if (useGlobalMM == false) { //build MM table by local data dt_mm = TheTool.dataTable_getMaxMinTable(dt_data);//generate MM table } DataTable dt_normal = TheTool.dataTable_MinMaxNormalization(dt_data, dt_mm); //--- Normalize Table : re-added column before save if (Crop2Col) { dt_normal.Columns.Add("time", typeof(string)).SetOrdinal(0); dt_normal.Columns.Add("id", typeof(string)).SetOrdinal(0); int r = 0; foreach (DataRow row in dt_normal.Rows) { row[0] = dt_temp.Rows[r][0].ToString(); row[1] = dt_temp.Rows[r][1].ToString(); r++; } } return(dt_normal); } catch (Exception ex) { TheSys.showError(ex); return(new DataTable()); } }
//**************************************************************************************** public static List <string> calEntropy_MotionData(String path_loadFrom, List <int[]> keyPostureRange , int degit, int col_combine_range) { List <string> final_output = new List <string>();//Data try { DataTable dt = CSVReader.ReadCSVFile(path_loadFrom, true); //prepare Data dt = TheTool.dataTable_cropCol(dt, 2, 0); //del first 2 Col TheTool.dataTable_roundValue(dt, degit); // eliminate decimal int start = -1; int end = 0; foreach (int[] keyPose in keyPostureRange) { DataTable dt_sub = TheTool.dataTable_selectRow_byIndex(dt, start, end); final_output.Add(start + " to " + end + "," + calEntrophy_1Action(dt_sub, col_combine_range)); } } catch (Exception ex) { TheSys.showError(ex); } return(final_output); }
void mainTable_getEachRecord(int fileID, string path) { try { //=========== Main Table ===================== TheTool_Stat.processing_file = path;//tell which file is in process, for Error report mainTable.Rows.Add(); mainTable.Rows[fileID][col_m_id] = fileID.ToString(); filename_current = TheTool.getFileName_byPath(path); mainTable.Rows[fileID][col_m_file] = filename_current; dataTable_calColumn_Class_oth(fileID, filename_current); //=========== cal from Subtable ============= //---- create Sub Table for each file ------- this.sub_table = CSVReader.ReadCSVFile(path, true); //---- Normalize ---------- subTable_normalize(); //------------------------- subTable_calJointEuclidian(fileID, sub_table); } catch (Exception e) { TheSys.showError("getEachRec: " + e.ToString(), true); } }
void readData(string fileName) { try { dataTable = CSVReader.ReadCSVFile(fileName, true); if (checkHide.IsChecked.Value == false) { dataGrid.ItemsSource = dataTable.DefaultView; dataGrid.AutoGenerateColumns = true; dataGrid.IsReadOnly = true; } row_count = dataTable.Rows.Count; txtRow.Content = "Row: " + row_count; if (row_count > 0) { butSplit.IsEnabled = true; } else { butSplit.IsEnabled = false; } } catch { } }
static public void getDataTable(string filePath) { dt_fullTable = CSVReader.ReadCSVFile(filePath, true); getMinMax_Euclidian(); }