diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-10-25 11:10:40 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-10-25 11:10:40 +0100 |
commit | 03073b44eaa801afc2faad7175669c2ee377838d (patch) | |
tree | c094638c54213764e25a6d178beb9df5e91fc0d5 /reader/reader.go | |
parent | e9aa53ccc3572bd17c22a3aa99851863cd2bde82 (diff) |
added test and some cleanup
Diffstat (limited to '')
-rw-r--r-- | reader/reader.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/reader/reader.go b/reader/reader.go index e4a6915..33e1773 100644 --- a/reader/reader.go +++ b/reader/reader.go @@ -2,6 +2,7 @@ package reader import ( "encoding/csv" + "errors" "fmt" "io" "io/ioutil" @@ -36,7 +37,7 @@ func ReadDML(path string) (*[]DatamapLine, error) { var s []DatamapLine data, err := ioutil.ReadFile(path) if err != nil { - return &s, &fileError{path, "Cannot open."} + return &s, errors.New("Cannot find file") } r := csv.NewReader(strings.NewReader(string(data))) for { @@ -45,7 +46,7 @@ func ReadDML(path string) (*[]DatamapLine, error) { break } if err != nil { - fmt.Printf("Cannot read line %s, ", err) + return &s, errors.New("Cannot read line %s") } if record[0] == "cell_key" { // this must be the header @@ -56,10 +57,6 @@ func ReadDML(path string) (*[]DatamapLine, error) { Sheet: strings.Trim(record[1], " "), Cellref: strings.Trim(record[2], " ")} s = append(s, dml) - // fmt.Printf("Key: %s; sheet: %s cellref: %s\n", dml.Key, dml.Sheet, dml.Cellref) - // klen, slen := Keylens(dml) - // fmt.Printf("Key length: %d\n", klen) - // fmt.Printf("Sheet length: %d\n\n", slen) } return &s, nil } |