Open danielzed opened 11 months ago
Having the exact same problem, my data file contains junk lines, and it would be nice to have a way to skip these...
Found it... Expected syntax is:
import (
"encoding/csv"
)
[...]
errHandler := func(err *csv.ParseError) bool {
fmt.Println(err)
return true
}
err = gocsv.UnmarshalFileWithErrorHandler(file, errHandler, &entries)
if err != nil { // Load clients from file
panic(err)
}
However I might extend this to tweak the behavior of the error handler, ie. I might either want to ignore the error (current behavior if true
is returned) or skip the row altogether.
help, unmarshalFile how can i skip line that fail. i suppose skip line that produce error is not supported. withErrorHandler can know which line is fail,but cannot skip that line or i can read each line and call UnmarshalBytes multiple times
want to know which way is suggested. thanks