Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delimiter ¶
Delimiter is an option for Read() and allows to change csv delimiter
Example ¶
package main
import (
"fmt"
"github.com/fabritsius/csvier"
)
func main() {
data, err := csvier.Read("./test_data/data.tsv",
csvier.Limit(5),
csvier.Delimiter('\t'),
)
if err != nil {
panic(err)
}
for _, r := range data {
fmt.Printf("%s fights with %s\n", r["NAME"], r["WEAPON"])
}
}
Output: Peter fights with Quad Blasters Gamora fights with Godslayer Rocket fights with Ion Cannon Groot fights with courage Drax fights with Dual Knives
func Index ¶
Index is an option for Read() and allows to change csv index (column names)
Example ¶
package main
import (
"fmt"
"github.com/fabritsius/csvier"
)
func main() {
data, err := csvier.Read("./test_data/data.csv",
csvier.Index([]string{"id", "name", "race", "weapon"}),
csvier.Skip(1),
csvier.Limit(5),
)
if err != nil {
panic(err)
}
for _, r := range data {
fmt.Printf("%s fights with %s.\n", r["name"], r["weapon"])
}
}
Output: Peter fights with Quad Blasters. Gamora fights with Godslayer. Rocket fights with Ion Cannon. Groot fights with courage. Drax fights with Dual Knives.
func Read ¶
Read function reads csv file and returns a map for each line
Example ¶
package main
import (
"fmt"
"github.com/fabritsius/csvier"
)
func main() {
data, err := csvier.Read("./test_data/data.csv")
if err != nil {
panic(err)
}
for _, r := range data {
fmt.Printf("%s fights with %s.\n", r["NAME"], r["WEAPON"])
}
}
Output: Peter fights with Quad Blasters. Gamora fights with Godslayer. Rocket fights with Ion Cannon. Groot fights with courage. Drax fights with Dual Knives. Nebula fights with Electroshock Batons.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.