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
+7.3k Golang : File system scanning
+9k Golang : Build and compile multiple source files
+8.3k Golang : Number guessing game with user input verification example
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+10.1k Golang : Compare files modify date example
+6.2k Linux/Unix : Commands that you need to be careful about
+17.3k Golang : How to tell if a file is compressed either gzip or zip ?
+7.3k Golang : Of hash table and hash map
+4.7k JavaScript: Add marker function on Google Map
+5k Golang : Constant and variable names in native language
+6k Golang : Experimenting with the Rejang script