csv

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

Example
package main

import (
	"fmt"

	"simonwaldherr.de/go/golibs/csv"
)

var userdata string = `id;name;email
0;John Doe;jDoe@example.org
1;Jane Doe;jane.doe@example.com
2;Max Mustermann;m.mustermann@alpha.tld`

func main() {
	csvmap, k := csv.LoadCSVfromString(userdata)

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

Example (Fourth)
package main

import (
	"fmt"

	"simonwaldherr.de/go/golibs/csv"
)

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

}
Output:

jDoe@example.org
Example (Second)
package main

import (
	"fmt"

	"simonwaldherr.de/go/golibs/csv"
)

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

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

Example (Third)
package main

import (
	"fmt"

	"simonwaldherr.de/go/golibs/csv"
)

var userdata2 string = `id;name;email
0;John Doe;jDoe@example.org`

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

}
Output:

jDoe@example.org

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL