Skip to content
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@ This library supports the following list of data types:
- "float64,array"
- "bool,array"
- json

## Example
- *string
- *int64
- *int
- *float64
- *bool
- *"string,array"
- *"int64,array"
- *"float64,array"
- *"bool,array"
- *json

## Examples

**Untyped example:**

Expand All @@ -58,13 +68,19 @@ import (
)

func main() {
data, _ := csvx.NewCSV(',', '#', true).ToMap([]byte(
`foo,bar,counter,names\n
csv := csvx.CSVParser{
Comma: ',',
Comment: '#',
TrimLeadingSpace: true,
SkipEmptyColumns: true,
}

data, _ := csv.Untyped([]byte(
`foo,bar,counter,names
hello,world,10,"hello,world,how,is,it,going"`))

fmt.Printf("untyped data:\n\t%+#v\n", data)
}

```

Result:
Expand All @@ -86,14 +102,20 @@ import (
)

func main() {
data2, _ := csvx.NewCSV(',', '#', true).ToTypedMap([]byte(
csv := csvx.CSVParser{
Comma: ',',
Comment: '#',
TrimLeadingSpace: true,
SkipEmptyColumns: true,
}

data, _ := csv.Typed([]byte(
`foo,bar,counter,names
string,string,int,"string,array"
hello,world,10,"hello,world,how,is,it,going"`))

fmt.Printf("typed data:\n\t%+#v\n", data2)
fmt.Printf("untyped data:\n\t%+#v\n", data)
}

```

Result:
Expand Down
Loading