Skip to content

Instantly share code, notes, and snippets.

@italojs
Created June 29, 2018 19:47
Show Gist options
  • Save italojs/beab353c06288ef04760506e4b9b6025 to your computer and use it in GitHub Desktop.
Save italojs/beab353c06288ef04760506e4b9b6025 to your computer and use it in GitHub Desktop.
package main
func readFile(path string) (record [][]string) {
//Open the file
file, err := os.Open(path)
if err != nil {
log.Fatalln("Error: ", err)
return
}
//Close the file when this method finish
defer file.Close()
//Read the file
reader := csv.NewReader(file)
record, err = reader.ReadAll()
if err != nil {
log.Fatalln("Error:", err)
return
}
return
}
func main() {
//Read the dataset
records := readFile("data.csv")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment