diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-08-05 16:57:27 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-08-05 16:57:27 +0100 |
commit | bc795edf4ff146d204aa08786572e27d4323866d (patch) | |
tree | cdbffc574678511e26506d610ee8486de764e912 | |
parent | 65d1a7d85ab4a18c4f3ac0fc98bb5fb969ccc020 (diff) |
added numfmt field to return_data table
-rw-r--r-- | pkg/datamaps/db.go | 5 | ||||
-rw-r--r-- | pkg/datamaps/writer.go | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go index a72a63c..80724ce 100644 --- a/pkg/datamaps/db.go +++ b/pkg/datamaps/db.go @@ -48,6 +48,7 @@ func setupDB(path string) (*sql.DB, error) { ret_id INTEGER, filename TEXT, value TEXT, + numfmt TEXT, FOREIGN KEY (dml_id) REFERENCES datamap_line(id) ON DELETE CASCADE @@ -236,13 +237,13 @@ func importXLSXtoDB(dmName string, returnName string, file string, db *sql.DB) e } // TODO - here we need to store the c.NumFmt string value in a new field - insertStmt, err := db.Prepare("insert into return_data (dml_id, ret_id, filename, value) values(?,?,?,?)") + insertStmt, err := db.Prepare("insert into return_data (dml_id, ret_id, filename, value, numfmt) values(?,?,?,?,?)") if err != nil { log.Fatal(err) } defer insertStmt.Close() - _, err = insertStmt.Exec(dmlID, retID, filename, cellData.Value) + _, err = insertStmt.Exec(dmlID, retID, filename, cellData.Value, cellData.NumFmt) if err != nil { log.Fatal(err) } diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go index 612fb74..a3c3698 100644 --- a/pkg/datamaps/writer.go +++ b/pkg/datamaps/writer.go @@ -89,8 +89,8 @@ func CreateMaster(opts *Options) error { return err } for masterData.Next() { - var key, filename, value string - if err := masterData.Scan(&key, &value, &filename); err != nil { + var key, filename, value, numFmt string + if err := masterData.Scan(&key, &value, &filename, &numFmt); err != nil { return err } values, err = appendValueMap(key, value, values) @@ -116,6 +116,7 @@ func CreateMaster(opts *Options) error { continue } dmlKey := datamapKeys[masterRow-1] + // TODO - we need to format the cells here too, e.g. dates if sl := r.WriteSlice(append([]string{dmlKey}, values[dmlKey]...), -1); sl == -1 { log.Printf("not a slice type") |