Last active
February 7, 2020 10:14
-
-
Save burakolgun/b4ce796cc08778e01a4762657f86dee5 to your computer and use it in GitHub Desktop.
Revisions
-
burakolgun revised this gist
Feb 7, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import ( ) func main() { csvfile, err := os.Open("test.csv") if err != nil { log.Fatal("Couldn't open the csv file", err) } -
burakolgun created this gist
Feb 7, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ package main import ( "encoding/csv" "fmt" "log" "io" ) func main() { csvfile, err := os.Open("test-csv.csv") if err != nil { log.Fatal("Couldn't open the csv file", err) } // Parse the file r := csv.NewReader(csvfile) // Iterate through the records for { // Read each record from csv record, err := r.Read() if err == io.EOF { break } if err != nil { log.Fatal(err) } fmt.Printf("column0: %s column1 %s column2: %s \n", record[0], record[1], record[2]) } }