Package: csvutils
Small utilities for reading CSV files into Go data structures — either raw rows
([][]string) or header-keyed maps ([]map[string]string).
Standard encoding/csv compliant, including quoted fields.
Repository: https://github.com/dracory/csvutils
Installation
go get github.com/dracory/csvutils
Usage
package main
import (
"log"
"github.com/dracory/csvutils"
)
func main() {
// Raw rows — records[0] holds headers
records, err := csvutils.ToArrays("data.csv")
if err != nil {
log.Fatal(err)
}
// Header-keyed maps with optional header renames
rows, err := csvutils.ToMaps("data.csv", map[string]string{
"First Name": "first_name",
})
if err != nil {
log.Fatal(err)
}
_ = records
_ = rows
}
Notes
- For querying CSV files with SQL, see the CSVDB driver in neat.