All Projects → artonge → go-csv-tag

artonge / go-csv-tag

Licence: GPL-3.0 License
Read csv file from go using tags

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-csv-tag

ShowMoreText
This is simple library for creating textview expandable. Like Continue or Less. This library extended versiion TextView. Easy to use.
Stars: ✭ 97 (+3.19%)
Mutual labels:  tags
tagflow
TagFlow is a file manager working with tags.
Stars: ✭ 22 (-76.6%)
Mutual labels:  tags
AlphaVantageAPI
An Opinionated AlphaVantage API Wrapper in Python 3.9. Compatible with Pandas TA (pip install pandas_ta). Get your FREE API Key at https://www.alphavantage.co/support/
Stars: ✭ 77 (-18.09%)
Mutual labels:  csv
magento2-module-catalog-import-command
Ⓜ️2️⃣ A Magento2 console command to import catalog files.
Stars: ✭ 31 (-67.02%)
Mutual labels:  csv
klar-EDA
A python library for automated exploratory data analysis
Stars: ✭ 15 (-84.04%)
Mutual labels:  csv
django-excel-response
Django package to easily render Excel spreadsheets
Stars: ✭ 74 (-21.28%)
Mutual labels:  csv
fb-page-chat-download
Python script to download messages from a Facebook page to a CSV file
Stars: ✭ 51 (-45.74%)
Mutual labels:  csv
scala-csv-parser
CSV parser library.
Stars: ✭ 24 (-74.47%)
Mutual labels:  csv
datamaker
Data generator command-line tool and library. Create JSON, CSV, XML data from templates.
Stars: ✭ 23 (-75.53%)
Mutual labels:  csv
org-clock-csv
Export Emacs org-mode clock entries to CSV format.
Stars: ✭ 80 (-14.89%)
Mutual labels:  csv
exoffice
Library to parse common excel formats (xls, xlsx, csv)
Stars: ✭ 31 (-67.02%)
Mutual labels:  csv
simplifai
Free automated deep learning for spreadsheets
Stars: ✭ 17 (-81.91%)
Mutual labels:  csv
Jekyll
Call of Duty XAsset exporter that dumps raw assets from a game's memory.
Stars: ✭ 29 (-69.15%)
Mutual labels:  csv
cfv
Command-line File Verify
Stars: ✭ 36 (-61.7%)
Mutual labels:  csv
tableschema-go
A Go library for working with Table Schema.
Stars: ✭ 41 (-56.38%)
Mutual labels:  csv
gatsby-simple-blog
an easily configurable gatsby-starter-blog with overreacted looking and tags, breadcrumbs, disqus, i18n, eslint, algolia supported
Stars: ✭ 48 (-48.94%)
Mutual labels:  tags
pcap-processor
Read and process pcap files using this nifty tool
Stars: ✭ 36 (-61.7%)
Mutual labels:  csv
smart-tagz
🏷Smart input tags for Vue
Stars: ✭ 28 (-70.21%)
Mutual labels:  tags
datatools
A set of tools for working with JSON, CSV and Excel workbooks
Stars: ✭ 68 (-27.66%)
Mutual labels:  csv
elm-csv
Decode CSV in the most boring way possible.
Stars: ✭ 23 (-75.53%)
Mutual labels:  csv

go-csv-tag

Read csv file from Go using tags

godoc for artonge/go-csv-tag

Go goreportcard for artonge/go-csv-tag

PRs Welcome

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:

name, ID, number
name1, 1, 1.2
name2, 2, 2.3
name3, 3, 3.4

Your Go code:

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
})

You can also load the data from an io.Reader with:

csvtag.LoadFromReader(youReader, &tab)

Or from a string with:

csvtag.LoadFromString(yourString, &tab)

Dump

Your Go code:

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:

err := csvtag.DumpToWriter(tab, yourIOWriter)

Or dump to a string with:

str, err := csvtag.DumpToString(tab)

The csv file written:

name,ID,number
some name,1,42.5
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].