Created
June 29, 2018 19:47
-
-
Save italojs/beab353c06288ef04760506e4b9b6025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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