aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/datamaps/writer.go
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-07-31 16:57:47 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-07-31 16:57:47 +0100
commita12c66e6c61303bfee84c8429e8b5946bfd8f158 (patch)
tree126eeff48e3acc9140dc2c58aa7a726721cf4397 /pkg/datamaps/writer.go
parenta39e4a5fde7ea3947b9c93149fda6c2833837e32 (diff)
starting writing the code for master writer
Diffstat (limited to 'pkg/datamaps/writer.go')
-rw-r--r--pkg/datamaps/writer.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go
new file mode 100644
index 0000000..9a7015b
--- /dev/null
+++ b/pkg/datamaps/writer.go
@@ -0,0 +1,40 @@
+package datamaps
+
+import (
+ "log"
+ "path/filepath"
+
+ "github.com/tealeg/xlsx/v3"
+)
+
+func ExportMaster(opts *Options) error {
+ // A master represents a set of file data from the database. Actually, in terms of the database,
+ // it should represent a "return".
+ //
+ // The meat of the master is of the format:
+ // Key 1 | Key_1_Value_for_FD_1 | Key_1_Value_for_FD_2 | Key_1_Value_for_FD_3 | ... etc
+ // Key 2 | Key_2_Value_for_FD_1 | Key_2_Value_for_FD_2 | Key_2_Value_for_FD_3 | ... etc
+ // Key 3 | Key_3_Value_for_FD_1 | Key_3_Value_for_FD_2 | Key_3_Value_for_FD_3 | ... etc
+ // ...
+ // Could be represented as a slice or a map[string][]string
+
+ // filename := filepath.Join(opts.MasterOutPutPath, "master.xlsx")
+ wb := xlsx.NewFile()
+ sh, err := wb.AddSheet("Master Data")
+
+ testRow, err := sh.Row(1)
+ if err != nil {
+ log.Fatal(err)
+ }
+ if sl := testRow.WriteSlice([]string{"Hello", "Bollocks", "Knackers", "Bottyies"}, -1); sl == -1 {
+ log.Printf("not a slice type")
+ }
+ log.Printf("writing slice to row\n")
+
+ log.Printf("saving master at %s", opts.MasterOutPutPath)
+ if err := wb.Save(filepath.Join(opts.MasterOutPutPath, "master.xlsx")); err != nil {
+ log.Fatalf("cannot save file to %s", opts.MasterOutPutPath)
+ }
+ sh.Close()
+ return nil
+}