csv库读取,双引号导致结果异常
问题:
**读取csv文件时,首字符双引号,导致结果异常,这里该如何避免?**
tmp.csv文件如下:
```
11,as"hello"-s,123,ppsid
11,"hello"-s,123,ppsid
```
主代码:
```go
func Test01() {
opencast, err := os.Open("./uploads/tmp.csv")
if err != nil {
log.Println("csv文件打开失败!")
}
defer opencast.Close()
ReadCsv := csv.NewReader(opencast)
ReadCsv.LazyQuotes = true
ReadCsv.FieldsPerRecord = -1
for {
read, err := ReadCsv.Read()
if err != nil && err != io.EOF {
log.Fatalf("can not read, err is %+v", err)
}
if err == io.EOF {
break
}
fmt.Println(read[1])
}
}
```
结果:
```go
as"hello"-s
hello"-s,123,ppsid
```