Golang encoding/csv.ParseError.Error() function example
package encoding/csv
A ParseError is returned for parsing errors. The first line is 1. The first column is 0.
Golang encoding/csv.ParseError.Error() function usage example
package main
import (
"encoding/csv"
"fmt"
"strings"
)
func main() {
// simulate a deformed csv data
csvreader := csv.NewReader(strings.NewReader("item2,item3,item4,item5\nitem6,"))
_, err := csvreader.ReadAll()
if err != nil {
fmt.Println(err.Error())
}
}
Output :
line 2, column 0: wrong number of fields in line
Reference :
Advertisement
Something interesting
Tutorials
+21.2k Golang : Get password from console input without echo or masked
+19.1k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+33.7k Golang : All update packages with go get command
+12.1k Golang : Save webcamera frames to video file
+11.6k Golang : Display a text file line by line with line number example
+9.3k Golang : Temperatures conversion example
+7.5k Golang : How to handle file size larger than available memory panic issue
+9.9k Golang : Translate language with language package example
+13k Golang : Calculate elapsed years or months since a date
+8.2k Golang : Routes multiplexer routing example with regular expression control
+13.3k Golang : Linear algebra and matrix calculation example
+6.9k Android Studio : Hello World example