本文主要是介绍golang csv parse error on line 1, column 1: bare “ in non-quoted-field,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题
csvFile, _ := os.Open("file.csv")reader := csv.NewReader(csvFile)records, err := reader.ReadAll()if err != nil {fmt.Println("无法读取:", err)return}
报错如下:
golang csv parse error on line 1, column 1: bare " in non-quoted-field
解决办法代码
由于再window下会有格式问题,添加两行代码可解决
csvFile, _ := os.Open("file.csv")reader := csv.NewReader(csvFile)reader.Comma = ',' //添加reader.LazyQuotes = true //添加records, err := reader.ReadAll()if err != nil {fmt.Println("无法读取:", err)return}
这篇关于golang csv parse error on line 1, column 1: bare “ in non-quoted-field的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!