Description
csvutil is a Go package for mapping between CSV data and Go values, with no external dependencies. It is not a CSV parser itself; it works on top of reader and writer interfaces such as those in Go's standard csv package, so you can plug in a different, faster CSV reader or writer if you need one. Unmarshal and Marshal give a quick path using the standard library's defaults, while Decoder and Encoder handle streaming and more advanced cases. The README covers working with headers that vary between files, keeping extra metadata columns through the Unused method, decoding files that have no header, normalizing data with Decoder.Map, custom separators, custom types and time formats, custom struct tags, slice and map fields, nested and embedded structs, and inline tags. It requires Go 1.18 or later.…
Highlights
- Marshal and Unmarshal between CSV and Go structs
- Streaming Decoder and Encoder for large or custom inputs
- Works with any reader or writer, including the standard csv package
- Handles missing headers, extra columns and custom separators
- Custom types, time formats, struct tags and nested structs
Ratings & Reviews
No ratings yet
Be the first to rate Csvutil.
People also visit
Csvutil FAQ
What does csvutil do?
It maps CSV records to Go values and back, using reader and writer interfaces such as Go's standard csv package. It is dependency free.
Is it a CSV parser?
No. It sits on top of a CSV reader or writer, which lets you swap in a different implementation if you need more performance.
How do I install it?
Run go get github.com/jszwec/csvutil. It requires Go 1.18 or later.
Can it handle CSV files without a header?
Yes. If you know the layout, you can define a struct, generate the header from it and pass it to a decoder.
What if my files have extra columns?
Decoder's Unused method reports which header indexes were not used after each Decode call, so you can capture and store the extra values.
What are the best Csvutil alternatives?
Popular alternatives to Csvutil include Stream Parser and Jsonriver. See all Csvutil alternatives


