Golang encoding/csv.Reader.Read() function example
package encoding/csv
Read reads one record from r (given input type). The record is a slice of strings with each string representing one field.
Golang encoding/csv.Reader.Read() function usage example
package main
import (
"encoding/csv"
"fmt"
"io"
"os"
)
func main() {
csvfile, err := os.Open("somecsvfile.csv")
if err != nil {
fmt.Println(err)
return
}
defer csvfile.Close()
reader := csv.NewReader(csvfile)
for {
record, err := reader.Read() // <----- here!
if err == io.EOF {
break
} else if err != nil {
fmt.Println(err)
return
}
fmt.Println(record) // out the csv content
}
}
Reference :
Advertisement
Something interesting
Tutorials
+12.2k Golang : Simple client-server HMAC authentication without SSL example
+6.5k Unix/Linux : How to get own IP address ?
+7.7k Golang : get the current working directory of a running program
+5.3k Golang : How to deal with configuration data?
+12.1k Golang : convert(cast) string to integer value
+20.8k Golang : Underscore or snake_case to camel case example
+6.9k Mac OSX : Find large files by size
+18.6k Golang : Generate thumbnails from images
+10.7k Golang : Underscore string example
+17.9k Golang : Login and logout a user after password verification and redirect example