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
+11.1k Golang : Roll the dice example
+18.8k Golang : How to make function callback or pass value from function as parameter?
+10.6k Golang : Select region of interest with mouse click and crop from image
+13.1k Golang : How to get a user home directory path?
+36k Golang : Get file last modified date and time
+17.6k Golang : delete and modify XML file content
+24k Golang : Call function from another package
+5.4k Javascript : How to loop over and parse JSON data?
+16.8k Golang : Get own process identifier
+8.8k Golang : Get final balance from bit coin address example
+6.9k Golang : Calculate BMI and risk category
+6k Golang : Function as an argument type example