Golang encoding/csv.Reader.ReadAll() function example
package encoding/csv
ReadAll reads all the remaining records from r(input source type). Each record is a slice of fields. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.
Golang encoding/csv.Reader.ReadAll() function usage example
package main
import (
"encoding/csv"
"fmt"
"strings"
)
func main() {
// simulate deformed csv data
csvreader := csv.NewReader(strings.NewReader("item1,item2,item3,item4,item5\nitem6,"))
_, err := csvreader.ReadAll() // <--- ReadAll()
if err != nil {
fmt.Println(err.Error())
}
}
Reference :
Advertisement
Something interesting
Tutorials
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+12.7k Golang : zlib compress file example
+9.3k Golang : How to get garbage collection data?
+8.1k Golang : Multiplexer with net/http and map
+11.7k Golang : Find age or leap age from date of birth example
+5.3k Javascript : Shuffle or randomize array example
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+8.4k Golang : Ackermann function example
+10k Golang : Read file and convert content to string
+13.1k Golang : Convert(cast) uintptr to string example
+6.1k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)