We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go version go1.17.6 linux/amd64
Yes
go env
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.17.6" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3228886816=/tmp/go-build -gno-record-gcc-switches"
Trying to parse a CSV file which has an escaped double quote at the end of line. I get an error that it has wrong number of fields.
Contents of test.csv that Fails:
test.csv
Fails
field_1,field_2 abc,"xy\" z"
Code to reproduce the issue:
package main import ( "encoding/csv" "fmt" "io" "log" "os" ) func main() { csvfile, err := os.Open("test.csv") if err != nil { log.Fatalln("Couldn't open the csv file", err) } r := csv.NewReader(csvfile) r.LazyQuotes = true // r.FieldsPerRecord = 0 for { record, err := r.Read() if err == io.EOF { break } if err != nil { log.Fatal(err) } fmt.Printf("%s,%s\n", record[0], record[1]) } }
$ go build main.go && ./main field_1,field_2 abc,xy" z
field_1,field_2 abc,xy\ 2022/02/01 23:18:41 record on line 3: wrong number of fields
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Trying to parse a CSV file which has an escaped double quote at the end of line. I get an error that it has wrong number of fields.
Contents of
test.csv
thatFails
:Code to reproduce the issue:
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: