go-csv

module
v0.0.0-...-1a8d693 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: MIT

README

go-csv

Go CSV that uses reflect like JSON

package main

import (
	"fmt"
	"log"

	"github.com/KalleDK/go-csv/csv"
)

type Record struct
{
	Name string
	Age int
}

var blob = []byte(`"Name","Age"
"Bob","12"
"Sally","13"
"Alice","10"
`)

func main() {
	var records []Record
	
	if err := csv.Unmarshal(&records, nil, blob); err != nil {
		log.Fatal(err)
	}

	fmt.Println(records)
	// Output:
	// [{Bob 12} {Sally 13} {Alice 10}]
}

Try on go playground https://play.golang.org/p/OS6P1e_Gs3s

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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