Skip to content

sodefrin/csv-decoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csv-decoder

GoDoc GitHub license

csv decoder.

Install

$ go get -u github.com/sodefrin/csv-decoder

requirements: go1.13

Usage

package main

import (
	"fmt"
	"log"
	"strings"

	csvdecoder "github.com/sodefrin/csv-decoder"
)

type sample struct {
	Test1 string
	Test2 int
}

func main() {
	out := []*sample{}

	// read "Test1,Test2\na,10\n" from filepath and parse
	if err := csvdecoder.Decode("filepath", &out); err != nil {
		log.Fatal(err)
	}

	for _, v := range out {
		fmt.Printf("%s %d", v.Test1, v.Test2)
		// Output:
		// a 10
	}
}

About

csv decoder to map string slice to struct.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages