aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/datamaps
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-07-28 07:59:34 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-07-28 07:59:34 +0100
commit6ecfdefdb5010ea0e74656525996f52de172cd02 (patch)
tree78e6de04690a6661efb9b18895eda6f7565ec823 /pkg/datamaps
parent79311f9f3d806b57168b7aba65235f2470555567 (diff)
reworked algorithm tha creates extractedData maps to allow the datamap sheet sequence to be any order
Diffstat (limited to '')
-rw-r--r--pkg/datamaps/reader.go13
-rw-r--r--pkg/datamaps/reader_test.go4
2 files changed, 5 insertions, 12 deletions
diff --git a/pkg/datamaps/reader.go b/pkg/datamaps/reader.go
index 4490d23..1b9a471 100644
--- a/pkg/datamaps/reader.go
+++ b/pkg/datamaps/reader.go
@@ -200,21 +200,18 @@ func ExtractDBDatamap(name string, file string, db *sql.DB) (extractedData, erro
names := getSheetNames(ddata)
outer := make(extractedData, len(names))
- var inner map[string]xlsx.Cell
+ // var inner map[string]xlsx.Cell
- seen := make(map[string]bool) // using this as a set to distinguish sheet names
+ for _, s := range names {
+ outer[s] = make(map[string]xlsx.Cell)
+ }
for _, i := range ddata {
sheet := i.Sheet
- if !seen[sheet] {
- seen[sheet] = true
- inner = make(map[string]xlsx.Cell) // we create a new inner when we get a new sheet
- }
cellref := i.Cellref
if val, ok := xdata[sheet][cellref]; ok {
- inner[cellref] = *val.Cell
- outer[sheet] = inner
+ outer[sheet][cellref] = *val.Cell
}
}
diff --git a/pkg/datamaps/reader_test.go b/pkg/datamaps/reader_test.go
index f784834..1a11b0d 100644
--- a/pkg/datamaps/reader_test.go
+++ b/pkg/datamaps/reader_test.go
@@ -187,10 +187,6 @@ func TestExtractUsingDBDM(t *testing.T) {
d[c.sheet][c.cellref].Value)
}
}
-
- if d["Another Sheet"]["E26"].Value != "Integer:" {
- t.Errorf("Expected E26 in Another Sheet sheet to be Integer: - instead it is %s", d["Another Sheet"]["E26"].Value)
- }
}
func TestExtract(t *testing.T) {