aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2019-11-14 20:14:07 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2019-11-14 20:14:07 +0000
commit9835833c0d1fc3c59c0619cc4cda5359ddba3a4c (patch)
tree7781c72abf9fae2feaf237d8a05e29faa94fff7c
parentf2fe102b3674d43144ec47e4df7246daef4626df (diff)
fixed - passing test
-rw-r--r--reader/reader.go6
-rw-r--r--reader/reader_test.go6
-rw-r--r--reader/testdata/datamap.csv2
-rw-r--r--reader/testdata/test_template.xlsxbin9039 -> 9221 bytes
4 files changed, 10 insertions, 4 deletions
diff --git a/reader/reader.go b/reader/reader.go
index 71870c5..55966af 100644
--- a/reader/reader.go
+++ b/reader/reader.go
@@ -173,14 +173,12 @@ func Extract(dm string, ssheet string) ExtractedData {
sheetNames := getSheetNames(dmlData)
output := make(ExtractedData, len(sheetNames))
+ inner := make(map[string]xlsx.Cell)
+
for _, i := range dmlData {
sheet := i.Sheet
cellref := i.Cellref
if val, ok := data[sheet][cellref]; ok {
- // TODO check what is happening here...
- // ddg "golang assingment to entry in nil map"
- // first SO entry, but I don't think I totally understand
- inner := make(map[string]xlsx.Cell)
inner[cellref] = *val.Cell
output[sheet] = inner
}
diff --git a/reader/reader_test.go b/reader/reader_test.go
index 3096c1b..eab6848 100644
--- a/reader/reader_test.go
+++ b/reader/reader_test.go
@@ -104,4 +104,10 @@ func TestExtract(t *testing.T) {
if d["Introduction"]["C9"].Value != "Test Department" {
t.Errorf("Expected C9 in Introduction sheet to be Test Department - instead it is %s", d["Introduction"]["C9"].Value)
}
+ if d["Introduction"]["J9"].Value != "Greedy Parrots" {
+ t.Errorf("Expected J9 in Introduction sheet to be Greedy Parrots - instead it is %s", d["Introduction"]["J9"].Value)
+ }
+ if d["Introduction"]["A1"].Value != "10" {
+ t.Errorf("Expected A1 in Introduction sheet to be 10 - instead it is %s", d["Introduction"]["A1"].Value)
+ }
}
diff --git a/reader/testdata/datamap.csv b/reader/testdata/datamap.csv
index d89db75..d1f3866 100644
--- a/reader/testdata/datamap.csv
+++ b/reader/testdata/datamap.csv
@@ -4,6 +4,8 @@ Department ,Introduction,C9
Delivery Body ,Introduction,C10
DRRDD - IPA ID Number,Introduction,C12
Controls Project ID number,Introduction,C13
+Jokey Entry,Introduction,A1
+Parrots Name,Introduction,J9
Project Type (for IPA use),Introduction,C14
Classification,Introduction,C15
DRRDD (GMPP - formally joined GMPP),Introduction,C16
diff --git a/reader/testdata/test_template.xlsx b/reader/testdata/test_template.xlsx
index 5e2ea97..97ddf63 100644
--- a/reader/testdata/test_template.xlsx
+++ b/reader/testdata/test_template.xlsx
Binary files differ