Created
January 4, 2022 06:56
-
-
Save horlabyc/5d9f9d6aaba6269c36d340dbb8487167 to your computer and use it in GitHub Desktop.
Create a Golang CSv reader
This file contains hidden or 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 | |
import ( | |
"encoding/csv" | |
"log" | |
"os" | |
) | |
func main() { | |
// CSV Reader | |
file, err := os.Open("games.csv") | |
var gameNames []string | |
var sales []float64 | |
if err != nil { | |
log.Fatal(err) | |
} | |
reader := csv.NewReader(file) | |
reader.LazyQuotes = true | |
records, err := reader.ReadAll() | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment