Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/earthboundkid/csv
Go CSV reader like Python's DictReader
https://github.com/earthboundkid/csv
csv csv-reader go golang
Last synced: 2 months ago
JSON representation
Go CSV reader like Python's DictReader
- Host: GitHub
- URL: https://github.com/earthboundkid/csv
- Owner: earthboundkid
- License: mit
- Created: 2017-08-09T03:07:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T12:41:34.000Z (6 months ago)
- Last Synced: 2024-10-16T13:39:42.775Z (3 months ago)
- Topics: csv, csv-reader, go, golang
- Language: Go
- Size: 22.5 KB
- Stars: 21
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# csv [![GoDoc](https://godoc.org/github.com/earthboundkid/csv?status.svg)](https://pkg.go.dev/github.com/earthboundkid/csv/v2) [![Go Report Card](https://goreportcard.com/badge/github.com/earthboundkid/csv/v2)](https://goreportcard.com/report/github.com/earthboundkid/csv/v2) [![Coverage Status](https://coveralls.io/repos/github/earthboundkid/csv/badge.svg)](https://coveralls.io/github/earthboundkid/csv)
Go CSV reader like Python's DictReader.
```
go get github.com/earthboundkid/csv/v2
```For performance comparison to other libraries, see [this benchmark gist](https://gist.github.com/earthboundkid/af8e9b612f7bc2ce1af419f2a7975ffc). As of this writing, this library is 40% faster and uses 70% less memory than its closest competitor.
## Example
Source CSV
```
first_name,last_name,username
"Rob","Pike",rob
Ken,Thompson,ken
"Robert","Griesemer","gri"
```User type
```go
type User struct {
Username string `csv:"username"`
First string `csv:"first_name"`
Last string `csv:"last_name"`
}
```Scanning file
```go
var user User
for err := range csv.Scan(csv.Options{Reader: src}, &user) {
if err != nil {
// Do something
}
fmt.Println(user.Username)
}
// Output:
// rob
// ken
// gri
```