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
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+6.1k Java : Human readable password generator
+24.6k Golang : How to validate URL the right way
+8.2k Golang : HttpRouter multiplexer routing example
+11k Golang : Replace a parameter's value inside a configuration file example
+10.9k Golang : How to transmit update file to client by HTTP request example
+10k Golang : Get escape characters \u form from unicode characters
+22.9k Golang : Gorilla mux routing example
+55.3k Golang : Unmarshal JSON from http response
+22.6k Generate checksum for a file in Go
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+14.2k Golang : syscall.Socket example