...

Package csv

import "simonwaldherr.de/go/golibs/csv"
Overview
Index
Examples

Overview ▾

Example

Code:

csvmap, k := csv.LoadCSVfromString(userdata)

for _, user := range csvmap {
    fmt.Println(user[k["email"]])
}

Example (Fourth)

Code:

csvmap, k := csv.LoadCSVfromFile("./test.csv")
for _, user := range csvmap {
    fmt.Println(user[k["email"]])
}

Output:

jDoe@example.org

Example (Second)

Code:

csvmap, k := csv.LoadCSVfromFile("./test.csv")

for _, user := range csvmap {
    fmt.Println(user[k["email"]])
}

Example (Third)

Code:

csvmap, k := csv.LoadCSVfromString(userdata2)
for _, user := range csvmap {
    fmt.Println(user[k["email"]])
}

Output:

jDoe@example.org

func GetHead

func GetHead(data map[int][]string) map[string]int

GetHead returns a map which represents the head of a csv map

func LoadCSVfromFile

func LoadCSVfromFile(filename string) (map[int][]string, map[string]int)

LoadCSVfromFile parses a CSV from a file and returns two maps one map with the data and another one with the csv head

func LoadCSVfromString

func LoadCSVfromString(csv string) (map[int][]string, map[string]int)

LoadCSVfromString parses a CSV from a string and returns two maps one map with the data and another one with the csv head