Skip to content

Commit e4a9b01

Browse files
author
Sven Obser
committed
Add configuration options to README
1 parent 8090e73 commit e4a9b01

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
Library to easily use *Kotlin Serialization* to serialize/parse CSV.
1010

11+
All types of record classes are supported (primitives, classes, enums, nested classes, ...).
12+
However, CSV serialization works best if the column number if fixed. So, collections (lists, sets, maps) and
13+
open classes should be avoided.
14+
1115
## Gradle Dependencies
1216
```kotlin
1317
// Kotlin Serialization CSV
@@ -60,6 +64,32 @@ fun main() {
6064
}
6165
```
6266

67+
### Pre-defined CSV formats
68+
The library comes with multiple pre-defined formats that can be used out of the box.
69+
70+
| Config | Description |
71+
|--- |--- |
72+
| `default` | Standard Comma Separated Value format, as for `rfc4180` but allowing empty lines. *Format is unstable and may change in upcoming versions.* |
73+
| `rfc4180` | Comma separated format as defined by [RFC 4180](http://tools.ietf.org/html/rfc4180). |
74+
| `excel` | Excel file format (using a comma as the value delimiter). |
75+
76+
### Configuration
77+
CSV serialization and parsing options can be changed by providing a custom `CsvConfiguration`.
78+
79+
| Option | Default Value | Description |
80+
|--- |--- | --- |
81+
| `delimiter` | `,` | The delimiter character between columns. |
82+
| `recordSeparator` | `\r\n` | The record separator. |
83+
| `quoteChar` | `"` | The quote character used to quote column values. |
84+
| `quoteMode` | `MINIMAL` | The quote mode used to decide if a column value should get quoted.<ul><li>`ALL`: Quotes *all* fields.</li><li>`ALL_NON_NULL`: Quotes all *non-null fields* and *fields which contain special characters*.</li><li>`ALL_NON_NUMERIC`: Quotes all *non-numeric fields* and *fields which contain special characters*.</li><li>`MINIMAL`: Quotes *fields which contain special characters*.</li><li>`NONE`: *Never* quotes fields (requires `CsvConfiguration.escapeChar` to be set).</li></ul> |
85+
| `escapeChar` | `null` (`\\` for `QuoteMode.NONE`) | The escape character used to escape reserved characters in a column value. |
86+
| `nullString` | *empty string* | The value to identify `null` values. |
87+
| `unitString` | `Unit` | The value to identify `Unit` values. |
88+
| `ignoreEmptyLines` | `true` | Ignore empty lines during parsing. |
89+
| `hasHeaderRecord` | `false` | First line is header record. |
90+
| `headerSeparator` | `.` | Character that is used to separate hierarchical header names. |
91+
| `hasTrailingDelimiter` | `false` | If records end with a trailing `delimiter`. |
92+
6393
## Requirements
6494

6595
| Dependency | Versions |

0 commit comments

Comments
 (0)