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.1k Golang : Sort and reverse sort a slice of runes
+14.4k Golang : How to filter a map's elements for faster lookup
+4.4k Linux/MacOSX : Search and delete files by extension
+4.9k Python : Find out the variable type and determine the type with simple test
+9.2k Golang : Create and shuffle deck of cards example
+8.5k Golang : How to check if input string is a word?
+14.8k Golang : Get URI segments by number and assign as variable example
+6k Golang : Function as an argument type example
+8.3k Golang : Oanda bot with Telegram and RSI example
+6.7k Golang : When to use make or new?
+19.3k Golang : Get host name or domain name from IP address
+14.6k Golang : Execute function at intervals or after some delay