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
+8.1k Golang : Variadic function arguments sanity check example
+13.9k Golang : How to check if a file is hidden?
+6k Linux/MacOSX : Search for files by filename and extension with find command
+10.6k Golang : Allow Cross-Origin Resource Sharing request
+9.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+7.4k Golang : Individual and total number of words counter example
+6.1k nginx : force all pages to be SSL
+5.6k Javascript : How to refresh page with JQuery ?
+18.4k Golang : Logging with logrus
+10.7k Golang : Get currencies exchange rates example
+7.1k Golang : Transform lisp or spinal case to Pascal case example
+8.5k PHP : How to parse ElasticSearch JSON ?