Standard library / encoding/csv
encoding/csv.NewReader()
Construct a CSV reader with comma delimiter, quote rules and automatic field-count inference from the first record. Expected stdout: '[a b]\n'.
Formal Syntax & Structure
go syntaxgo
func NewReader(r io.Reader) *ReaderParameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | io.Reader | Source reader. |
Return Value
*Reader
New CSV reader.
Working Example
Example Snippetgo
package main
import ( "encoding/csv" "fmt" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { r := csv.NewReader(strings.NewReader("a,b\n")) x, e := r.Read() must(e) fmt.Println(x)}