My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
CSVStrategy  
The CSVStrategy is used to specify the format of the CSV file
Updated Aug 25, 2012 by skiron...@gmail.com

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.

Comment by patrick....@gmail.com, Jan 9, 2013

Typo above: "CSVStrategy_UK_DEFAULT" should be "CSVStrategy.UK_DEFAULT"

Comment by dinuk...@gmail.com, Dec 3, 2013

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)...;

Powered by Google Project Hosting