The CSVStrategy
You can specify your own csv format by passing a CSVStrategy object to the CSVReader:
new CSVReaderBuilder<MyClass>.(csvFileReader).strategy(myStrategy)...;
The CSVStrategy specifies the format of the csv file and the behaviour of the CSVReader. There are various parameters that can be configured:
- delimiter char: the seperator of the tokens
- quoteCharacter char: the quote character
- commentIndicator char: the comment indicator char
- skipHeader boolean: if true, skips the first line
- ignoreEmptyLines boolean: if true, ignores empty lines
Defaults
jCSV comes with some default implementations for the CSVStrategy:
| name | delimiter | quote character | comment indicator | skip headers? | ignore empty lines |
| CSVStrategy.DEFAULT | ; | " | # | no | yes |
| CSVStrategy_UK_DEFAULT | , | " | # | no | yes |
If you don't specifiy a CSVStrategy, CSVStrategy.DEFAULT will be used as default.
Typo above: "CSVStrategy_UK_DEFAULT" should be "CSVStrategy.UK_DEFAULT"
Above example "new CSVReaderBuilder<MyClass>.(csvFileReader).strategy(myStrategy)...;" is incorrect because there's an unwanted dot after the generics declaration. it should be corrected as
new CSVReaderBuilder<MyClass> (csvFileReader).strategy(myStrategy)...;