public (bool, string) GetElevdataFromQresFinder(QresFinder qrf) { if (!qrf.Exists()) { return(false, "Qrf could not find data"); } var text = qrf.GetText(); var textar = text.Split('\n'); var df = new SimpleDf(); df.ReadCsv(textar); var rv = ProcessDf(df); return(rv); }
public (bool, string) GetElevdataFromCsvFile(string fname) { bool ok = false; var errmsg = "no error"; if (!File.Exists(fname)) { heights = new List <float>();; errmsg = $"File {fname} does not exist"; return(ok, errmsg); } var df = new SimpleDf(); df.ReadCsv(fname); return(ProcessDf(df)); }
public void SimpleTest() { var sdf = new SimpleDf("sdf"); sdf.preferedType["id"] = SdfColType.dfint; sdf.preferedType["dt"] = SdfColType.dfdatetime; sdf.preferedFormat["dt"] = "yyyy-MM-dd HH:mm:ss"; sdf.preferedSubstitute["dt"] = ("+00", ""); sdf.ReadCsv(sdflines); Assert.True(sdf.Nrow() == 3); Assert.True(sdf.Ncol() == 5); Assert.True(sdf.InfoClassStr() == "Classes:id:dfint,x:dfdouble,y:dfdouble,dt:dfdatetime,n:dfstring"); Assert.True(sdf.GetIntCol("id").Sum() == 6); Assert.True(sdf.GetDoubleCol("x").Sum() == 6); Assert.True(sdf.GetDoubleCol("y").Sum() == 9); Assert.True(sdf.DataErrors() == 0); // Use the Assert class to test conditions }
public void Load(string startFilterDate, string endFilterDate) { try { ResolveFullCsvName(); Debug.Log("Load " + fullcsvname); sdf = new SimpleDf(); sdf.comment = clr; sdf.CheckConsistency("Before Load"); sdf.preferedType["Id"] = SdfColType.dflong; sdf.preferedType["Timestamp"] = SdfColType.dfdatetime; sdf.preferedFormat["Timestamp"] = "yyyy-MM-dd HH:mm:ss.fff"; sdf.preferedType["time"] = SdfColType.dfdatetime; sdf.preferedFormat["time"] = "yyyy/MM/dd HH:mm:ss.fff"; sdf.preferedSubstitute["time"] = ("+00", ""); sdf.ReadCsv(fullcsvname, quiet: false); Debug.Log($"Read {sdf.InfoStr()}"); Debug.Log($"Cols: {sdf.InfoClassStr()}"); Debug.Log($"Copying {sdf.InfoStr()}"); var test = false; if (test) { testsdf(sdf, startFilterDate, endFilterDate); } var tcolname = "Timestamp"; isdozertrack = true; if (sdf.ColumnExists("time")) { tcolname = "time"; isdozertrack = false; } sdf.KeepColumns(new string[] { "Id", "Timestamp", "x", "y", "time", "X", "Y" }); sdf = SimpleDf.SortOnColumn(sdf, tcolname); if (isdozertrack) { var blst = sdf.GetBoolFilter("Timestamp", startFilterDate, endFilterDate); sdf = SimpleDf.Subset(sdf, "df", blst); } else { sdf.RenameColumn("X", "x"); sdf.RenameColumn("Y", "y"); } sdf.FloatTimeFromDateString(tcolname, "Elaptime"); sdf.preferedFormat["Elaptime"] = "f2"; test = true; if (test) { sdf.WriteCsv("transformed_df.csv"); } var nrow = sdf.Nrow(); if (nrow == 0) { Debug.LogWarning("No rows in df " + fullcsvname); sdf = null; } } catch (Exception ex) { Debug.LogError("Exception in DozerTracks.Load:" + ex.ToString()); } }