Created
January 4, 2022 18:54
-
-
Save jeffotoni/3a4df93d69968c51bda7b393350ea764 to your computer and use it in GitHub Desktop.
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" | |
"fmt" | |
"os" | |
) | |
type empData struct { | |
Name string | |
Age string | |
City string | |
} | |
func main() { | |
csvFile, err := os.Open("funcionarios.csv") | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("Successfully Opened CSV file") | |
defer csvFile.Close() | |
csvLines, err := csv.NewReader(csvFile).ReadAll() | |
if err != nil { | |
fmt.Println(err) | |
} | |
for _, line := range csvLines { | |
emp := empData{ | |
Name: line[0], | |
Age: line[1], | |
City: line[2], | |
} | |
fmt.Println(emp.Name + " " + emp.Age + " " + emp.City) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment