Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/loov/csvcolumn

CSV column reader
https://github.com/loov/csvcolumn

Last synced: 7 days ago
JSON representation

CSV column reader

Awesome Lists containing this project

README

        

# csvcolumn

[![GoDoc](https://godoc.org/github.com/loov/csvcolumn?status.svg)](http://godoc.org/github.com/loov/csvcolumn)

csvcolumn package implements convenient CSV reading with column access.

Internally it uses https://golang.org/pkg/encoding/csv/,
which means it inherits all the same restrictions.

``` go
const CSV = `Index,Age,Name
1,52,Alice
5,42,Bob
512,31,Charlie
`

func Example() {
source := strings.NewReader(CSV)

data := csvcolumn.NewReader(source)
data.LazyQuotes = true
name, age := data.String("Name"), data.Int("Age")

for data.Next() && data.Err() == nil {
fmt.Println(*name, *age)
}

if data.Err() != nil {
fmt.Println(data.Err())
}
}
```