0
The code reads the file successfully until it hangs on line 6, which has a comma in the middle, I took the comma off line 6, and the err went to line 8 and so on. How do I read the file? ignoring the commas, first time messing with csv file.
Example csv:
Produtos;preco;data
...
camiseta,outros;60;20/10/20019 (a vírgula separando)
O erro:
2019/10/22 20:19:49 record on line 6: wrong number of fields
exit status 1
package main
import (
"encoding/csv"
"fmt"
"log"
"os"
"io"
)
func main() {
csvfile, ferr := os.Open("teste/ncm.csv")
if ferr != nil {
log.Fatal(ferr)
}
r := csv.NewReader(csvfile)
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
fmt.Println(record)
}
}
Value! Now he’s read the whole file.
– NelsonThiago