MultiCSV is a multi reader that's the logical concatenation of the provided input csv readers. They're read sequentially. Once all inputs have returned EOF, Read will return EOF. If any of the readers return a non-nil, non-EOF error, Read will return that error.
go get -u github.com/zero-pkg/multicsv
r := multicsv.NewReader(
multicsv.LazyFileReader("data/users.csv", true),
multicsv.LazyFileReader("data/users2.csv", true),
)
records, err := r.ReadAll()
if err != nil {
panic(err)
}
fmt.Println(records)
func main() {
r := multicsv.NewReader(
customReader("data/count_10.csv"),
customReader("data/count_100.csv"),
)
}
func customReader(file string) *multicsv.LazyReader {
return &multicsv.LazyReader{
Init: func() (*csv.Reader, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
// customize csv.Reader
r := csv.NewReader(f)
r.LazyQuotes = true
return r, nil
},
}
}