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
+18.5k Golang : Write file with io.WriteString
+37.5k Upload multiple files with Go
+15.2k Golang : How to add color to string?
+9.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+9.1k Golang : Get curl -I or head data from URL example
+8.3k Swift : Convert (cast) Character to Integer?
+8.3k Golang : Emulate NumPy way of creating matrix example
+22.1k Golang : Join arrays or slices example
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+5.3k Python : Convert(cast) string to bytes example
+13k Golang : Get terminal width and height example