How to use quotes and delimiter?
michaelwijnands opened this issue · 1 comments
michaelwijnands commented
Hi,
I know I can create a custom CSV reader with: gocsv.SetCSVReader
and that I can then assign a Comma:
gocsv.SetCSVReader(func(in io.Reader) gocsv.CSVReader {
r := csv.NewReader(in)
r.Comma = ';'
return r
})
However, I would also like to allow quotes in my file which should be possible with LazyCSVReader.
I tried to combine them but Comma doesn't exist for LazyCSVReader.
gocsv.SetCSVReader(func(in io.Reader) gocsv.CSVReader {
r := gocsv.LazyCSVReader(in)
r.Comma = ';'
return r
})
which results in:
Unresolved reference 'Comma'
How to achieve this?
dewey commented
The documentation says:
LazyCSVReader returns a lazy CSV reader, with LazyQuotes and TrimLeadingSpace.
So just add r.LazyQuotes = true to your custom CSV reader. LazyCSVReader
is just a wrapper.