diff --git a/README.md b/README.md index ac2d42c..698e4b8 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,26 @@ # xsv + csv handling package written in go +[![Licence](https://img.shields.io/github/license/shigetaichi/xsv)](https://github.com/shigetaichi/xsv/blob/main/LICENSE) +[![Code Size](https://img.shields.io/github/languages/code-size/shigetaichi/xsv)](https://github.com/shigetaichi/xsv) +[![Release](https://img.shields.io/github/v/release/shigetaichi/xsv)](https://github.com/shigetaichi/xsv/releases) +[![Github Stars](https://img.shields.io/github/stars/shigetaichi/xsv)](https://github.com/shigetaichi/xsv/stargazers) + Most of the programs related to csv generation and reading are created from code in this repository.↓ > Copyright (c) 2014 Jonathan Picques > https://github.com/gocarina/gocsv - + ※xsv does not include gocsv. -## Getting Started +## 🚀Getting Started ``` go get github.com/shigetaichi/xsv ``` -## Usage +## 🔨Usage ```go package main @@ -64,8 +70,32 @@ func main() { var clientOutput []*Client err = xsvRead.SetFileReader(clientsFile).ReadTo(&clientOutput) if err != nil { - return + return } } -``` \ No newline at end of file +``` + +## 🛠️Details + +### XsvWrite + +| FieldName | Type | Description | +|-----------------|-------------------|---------------------------------------------------------------| +| TagName | string | key in the struct field's tag to scan | +| TagSeparator | string | separator string for multiple csv tags in struct fields | +| OmitHeaders | bool | whether to output headers to csv or not | +| SelectedColumns | []string | slice of field names(which is set in "TagName" tag) to output | +| SortOrder | []uint | column sort order | +| HeaderModifier | map[string]string | map to dynamically change headers | + +### XsvRead + +| FieldName | Type | Description | +|-------------------------------------------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| TagName | string | key in the struct field's tag to scan | +| TagSeparator | string | separator string for multiple csv tags in struct fields | +| FailIfUnmatchedStructTags | bool | indicates whether it is considered an error when there is an unmatched struct tag. | +| FailIfDoubleHeaderNames | bool | indicates whether it is considered an error when a header name is repeated in the csv header. | +| ShouldAlignDuplicateHeadersWithStructFieldOrder | bool | indicates whether we should align duplicate CSV headers per their alignment in the struct definition. | +| NameNormalizer | Normalizer(func(string) string) | Normalizer is a function that takes and returns a string. It is applied to struct and header field values before they are compared. It can be used to alter names for comparison. For instance, you could allow case insensitive matching or convert '-' to '_'. |