improve csv error check

This commit is contained in:
interfisch 2021-05-24 17:52:58 +02:00
parent d5a60cd499
commit dfc53c494b
1 changed files with 32 additions and 17 deletions

View File

@ -8,7 +8,7 @@ TODO
int vis_textsize=12; //copy from Visualization class int vis_textsize=12; //copy from Visualization class
//String logfile_name="LOG00008_rumfahren_neu.TXT"; //String logfile_name="LOG00008_rumfahren_neu.TXT";
String logfile_name="LOG00184_20210515b_Video_Treff_FreewheelCurrentFix.TXT"; String logfile_name="20210524_Phaseadvance_enabled.TXT";
int columnCount=20; int columnCount=20;
boolean useSerial=false; //false=read from csv log, true=read from serial port boolean useSerial=false; //false=read from csv log, true=read from serial port
@ -109,12 +109,25 @@ void setup() {
serialString = null; serialString = null;
}else{ }else{
logdata = loadTable(logfile_name, "header, csv"); logdata = loadTable(logfile_name, "header, csv");
float _checkTimeLast=-100;
for (int i=0; i < logdata.getRowCount();i++) { for (int i=0; i < logdata.getRowCount();i++) {
float _checkTimeCurrent=logdata.getRow(i).getFloat("time")*1000;
if (logdata.getRow(i).getString(0).charAt(0)=='#') { //check if row starts with # (comment) if (logdata.getRow(i).getString(0).charAt(0)=='#') { //check if row starts with # (comment)
print("removed row:"); print("removed comment:");
for (int is=0;is< logdata.getRow(i).getColumnCount(); is++) for (int is=0;is< logdata.getRow(i).getColumnCount() && logdata.getRow(i).getString(is) != null; is++)
{ {
print(logdata.getRow(i).getString(is)+","); print(", "+logdata.getRow(i).getString(is));
}
println();
logdata.removeRow(i);
}else if (Float.isNaN(_checkTimeCurrent) || _checkTimeCurrent <= _checkTimeLast) { //check if time is plausible
print("removed unplausible time:");
for (int is=0;is< logdata.getRow(i).getColumnCount() && logdata.getRow(i).getString(is) != null; is++)
{
print(", "+logdata.getRow(i).getString(is));
} }
println(); println();
logdata.removeRow(i); logdata.removeRow(i);
@ -122,7 +135,7 @@ void setup() {
} }
logdata_start_time=logdata.getRow(0).getFloat("time"); logdata_start_time=logdata.getRow(0).getFloat("time");
logdata_end_time = logdata.getRow(logdata.getRowCount()-1).getFloat("time"); logdata_end_time = logdata.getRow(logdata.getRowCount()-1).getFloat("time");
println("loaded "+logdata.getRowCount()+" lines. Times: "+logdata_start_time+"s to "+logdata_end_time+"s"); println("loaded "+logdata.getRowCount()+" lines. Starttime: "+logdata_start_time+"s , Endtime: "+logdata_end_time+"s");
} }
PVector pos_vis_cmd = new PVector(100,200); PVector pos_vis_cmd = new PVector(100,200);
@ -237,9 +250,11 @@ void setup() {
if (showTimeline) { if (showTimeline) {
println("Preparing Timeline");
tl = new Timeline(30,height-30, width-30*2, 28); tl = new Timeline(30,height-30, width-30*2, 28);
tl.setTimes(logdata_start_time,logdata_end_time); tl.setTimes(logdata_start_time,logdata_end_time);
tl.generatePreview(logdata); tl.generatePreview(logdata);
println("Timeline prepared");
} }
} }