Skip to content

Commit

Permalink
feat: README.md (#9)
Browse files Browse the repository at this point in the history
* feat: README.md

* add: shields.io

* fix: table row

* fix: add HeaderModifier
  • Loading branch information
shigetaichi authored Sep 4, 2023
1 parent 46922c1 commit f1c62f9
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -64,8 +70,32 @@ func main() {
var clientOutput []*Client
err = xsvRead.SetFileReader(clientsFile).ReadTo(&clientOutput)
if err != nil {
return
return
}
}

```
```

## 🛠️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 '_'. |

0 comments on commit f1c62f9

Please sign in to comment.