Fast reader for delimiter-separated data in Go.
- Supports CSV, TSV, PSV.
- Supports user defined delimiter.
- Dependency-free.
- Optimized for speed.
- Based on Aliaksandr Valialkin's TSVReader
See docs.
Go version 1.17+
go get github.com/cristalhq/dsvreader
bs := bytes.NewBufferString(
`foo\t42\n
bar\t123\n`)
r := dsvreader.NewTSV(bs)
for r.Next() {
col1 := r.String()
col2 := r.Int()
fmt.Printf("col1=%s, col2=%d\n", col1, col2)
}
if err := r.Error(); err != nil {
panic("unexpected error: %s", err)
}
See examples: example_test.go.