diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-12 12:51:22 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-12 12:52:01 +0000 |
commit | a50c61f4d31cf3cc30222554bd171dbf66603668 (patch) | |
tree | 2fe1e4cb8d223b763d201bbd873031704ca374a3 | |
parent | 00351bfbe0b4ff5af723834ba37f2f41214f566e (diff) |
removed superceded func and old TODOs
-rw-r--r-- | reader/reader.go | 24 | ||||
-rw-r--r-- | reader/reader_test.go | 19 |
2 files changed, 3 insertions, 40 deletions
diff --git a/reader/reader.go b/reader/reader.go index 1d0dbf5..7153120 100644 --- a/reader/reader.go +++ b/reader/reader.go @@ -120,7 +120,7 @@ func cols(n int) []string { //ReadXLSToMap returns the file's data as a map, // keyed on sheet name. All values are returned as strings. // Paths to a datamap and the spreadsheet file required. -func ReadXLSToMap(dm string, ssheet string) FileData { +func ReadXLS(dm string, ssheet string) FileData { // open the files excelData, err := xlsx.OpenFile(ssheet) @@ -152,25 +152,3 @@ func ReadXLSToMap(dm string, ssheet string) FileData { } return output } - -//ReadXLSX reads an XLSX file -func ReadXLSX(fn string) []ExtractedCell { - var out []ExtractedCell - f, err := xlsx.OpenFile(fn) - if err != nil { - fmt.Printf("Cannot open %s", fn) - } - for _, sheet := range f.Sheets { - for rowLidx, row := range sheet.Rows { - for colLidx, cell := range row.Cells { - ex := ExtractedCell{ - Cell: cell, - ColL: colstream[colLidx], - RowLidx: rowLidx + 1, - Value: cell.Value} - out = append(out, ex) - } - } - } - return out -} diff --git a/reader/reader_test.go b/reader/reader_test.go index deb9568..d79de14 100644 --- a/reader/reader_test.go +++ b/reader/reader_test.go @@ -38,19 +38,6 @@ func TestBadDMLLine(t *testing.T) { } } -func TestReadXLSX(t *testing.T) { - data := ReadXLSX("testdata/test_template.xlsx") - if data[0].ColL != "A" { - t.Errorf("Expected data[0].colL to be A, got %v", data[0].ColL) - } - if data[0].Value != "Date:" { - t.Errorf("Expected data[0].value to be Date:, got %v", data[0].Value) - } - if data[0].RowLidx != 2 { - t.Errorf("Expected data[0].rowLidx to be 2, got %v", data[0].RowLidx) - } -} - func TestAlphaStream(t *testing.T) { if colstream[26] != "AA" { t.Errorf("Expected AA, got %v", colstream[26]) @@ -99,16 +86,14 @@ func TestGetSheetsFromDM(t *testing.T) { } } -func TestReadXLSXToMap(t *testing.T) { - d := ReadXLSToMap("testdata/datamap.csv", "testdata/test_template.xlsx") +func TestReadXLSX(t *testing.T) { + d := ReadXLS("testdata/datamap.csv", "testdata/test_template.xlsx") if d["Summary"]["A2"].Value != "Date:" { t.Errorf("Expected A2 in Summary sheet to be 'Date:' - instead it is %s", d["Summary"]["A2"].Value) } - // TODO we actually want this to return an float - do we? if d["Another Sheet"]["F5"].Value != "4.2" { t.Errorf("Expected F5 in Another Sheet sheet to be 4.2 - instead it is %s", d["Another Sheet"]["F5"].Value) } - // TODO we actually want this to return an integer - do we? if d["Another Sheet"]["J22"].Value != "18" { t.Errorf("Expected J22 in Another Sheet sheet to be 18 - instead it is %s", d["Another Sheet"]["J22"].Value) } |