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
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.
+10.8k Golang : Command line file upload program to server example
+19.3k Golang : Calculate entire request body length during run time
+14.6k Golang : Missing Bazaar command
+8.8k Golang : Random integer with rand.Seed() within a given range
+7.2k Golang : Dealing with postal or zip code example
+8.2k Golang : Qt splash screen with delay example
+17.9k Golang : Qt image viewer example
+14.4k Golang : On enumeration
+9.7k Golang : Find correlation coefficient example
+18.6k Golang : Get download file size
+11.1k Golang : Simple image viewer with Go-GTK