Started working on unit tests

Fixed some bugs in the CSVColumn processor
This commit is contained in:
Leon Mika 2023-04-24 04:08:46 +00:00
parent 1c08248c69
commit 8c7e9453ee
3 changed files with 70 additions and 5 deletions

5
csv.go
View file

@ -9,6 +9,7 @@ import (
func CSVColumn(name string) func(r io.Reader, w io.Writer) error {
return func(r io.Reader, w io.Writer) error {
cr := csv.NewReader(r)
cr.FieldsPerRecord = -1
header, err := cr.Read()
if err != nil {
@ -34,7 +35,7 @@ func CSVColumn(name string) func(r io.Reader, w io.Writer) error {
return err
}
}
if len(rec) < colIdx {
if len(rec) <= colIdx {
continue
}
@ -46,4 +47,4 @@ func CSVColumn(name string) func(r io.Reader, w io.Writer) error {
}
}
}
}
}