Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artonge/go-csv-tag
Read csv file from go using tags
https://github.com/artonge/go-csv-tag
csv go hacktoberfest tags
Last synced: 24 days ago
JSON representation
Read csv file from go using tags
- Host: GitHub
- URL: https://github.com/artonge/go-csv-tag
- Owner: artonge
- License: gpl-3.0
- Created: 2017-06-18T15:31:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T09:15:49.000Z (4 months ago)
- Last Synced: 2024-01-30T04:48:29.318Z (4 months ago)
- Topics: csv, go, hacktoberfest, tags
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 112
- Watchers: 3
- Forks: 31
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Lists
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go-extra - go-csv-tag - 06-18T15:31:16Z|2021-11-14T17:04:52Z| (File Handling / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go-cn - go-csv-tag - csv-tag) (文件处理 / 检索及分析资料库)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Advanced Console UIs)
- awesome-go-projects - go-csv-tag - Load csv file using tag. (File Handling / Standard CLI)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go - go-csv-tag - | - | - | (Files / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go-with-framework - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go-cn - go-csv-tag - csv-tag) (文件处理 / 检索及分析资料库)
- awesome-stars - go-csv-tag
- awesome-go-cn - go-csv-tag
- awesome-go - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go-stars - go-csv-tag(stars: 112) - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go - go-csv-tag - 使用标签从go中读取csv文件。 (<span id="文件-files">文件 Files</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go. - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go-with-stars - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Advanced Console UIs)
- repo-1316-awesome-go-cn - go-csv-tag - csv-tag) (文件处理 / 检索及分析资料库)
- repo-1211-awesome-go-cn - go-csv-tag - csv-tag) (文件处理 / 检索及分析资料库)
- awesome-Char - go-csv-tag - Load csv file using tag. (File Handling / Advanced Console UIs)
- awesome-reader - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- Go-awesome - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- go-awesome-cn-star - go-csv-tag
- awesome-go - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go-handwritten - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go2 - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. (Files / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. - :arrow_down:3 - :star:23 (Files / Advanced Console UIs)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Advanced Console UIs)
- awesome-go-zh - go-csv-tag - csv-tag) (文件处理 / 检索及分析资料库)
- awesome-go-cn - go-csv-tag
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go - go-csv-tag - Load csv file using tag. (File Handling / Search and Analytic Databases)
- awesome-go-cn - go-csv-tag
- awesome-go - go-csv-tag - Read csv file from go using tags - ★ 34 (Files)
README
# go-csv-tag
Read csv file from Go using tags
[![godoc for artonge/go-csv-tag](https://godoc.org/github.com/artonge/go-csv-tag?status.svg)](http://godoc.org/github.com/artonge/go-csv-tag)
![Go](https://github.com/artonge/go-csv-tag/workflows/Go/badge.svg)
[![goreportcard for artonge/go-csv-tag](https://goreportcard.com/badge/github.com/artonge/go-csv-tag)](https://goreportcard.com/report/artonge/go-csv-tag)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
**The project is in maintenance mode.**
It is kept compatible with changes in the Go ecosystem but no new features will be developed. PR could be accepted.
# Install
`go get github.com/artonge/go-csv-tag/v2`
# Example
## Load
The csv file:
```csv
name, ID, number
name1, 1, 1.2
name2, 2, 2.3
name3, 3, 3.4
```Your Go code:
```go
type Demo struct { // A structure with tags
Name string `csv:"name"`
ID int `csv:"ID"`
Num float64 `csv:"number"`
}tab := []Demo{} // Create the slice where to put the content
err := csvtag.LoadFromPath(
"file.csv", // Path of the csv file
&tab, // A pointer to the create slice
csvtag.CsvOptions{ // Load your csv with optional options
Separator: ';', // changes the values separator, default to ','
Header: []string{"name", "ID", "number"}, // specify custom headers
TagKey: "csv", // specify a custom tag key, default to 'csv'
})
```You can also load the data from an io.Reader with:
```go
csvtag.LoadFromReader(youReader, &tab)
```Or from a string with:
```go
csvtag.LoadFromString(yourString, &tab)
```## Dump
Your Go code:
```go
type Demo struct { // A structure with tags
Name string `csv:"name"`
ID int `csv:"ID"`
Num float64 `csv:"number"`
}tab := []Demo{ // Create the slice where to put the content
Demo{
Name: "some name",
ID: 1,
Num: 42.5,
},
}err := csvtag.DumpToFile(tab, "csv_file_name.csv")
```You can also dump the data into an io.Writer with:
```go
err := csvtag.DumpToWriter(tab, yourIOWriter)
```Or dump to a string with:
```go
str, err := csvtag.DumpToString(tab)
```The csv file written:
```csv
name,ID,number
some name,1,42.5
```