Skip to content

Instantly share code, notes, and snippets.

@ivan-loh
Created December 25, 2016 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivan-loh/c92e1b3db986617cdc8064beda41afac to your computer and use it in GitHub Desktop.
Save ivan-loh/c92e1b3db986617cdc8064beda41afac to your computer and use it in GitHub Desktop.
reading some csv file
package main
import (
"bufio"
"encoding/csv"
"fmt"
"io"
"log"
"os"
)
func main() {
f, _ := os.Open("some/file")
r := csv.NewReader(bufio.NewReader(f))
for {
record, err := r.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
fmt.Println(record)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment