-
Notifications
You must be signed in to change notification settings - Fork 4
4 Reading a CSV document
Dan Geabunea edited this page Apr 1, 2015
·
1 revision
The code bellow illustrates how to read a CSV document, with the default reading configuration. All the CSV rows and columns will be imported.
String csvPath = "\home\user\document.csv"
CsvDocument document = CsvDocument.read(csvPath);
The code bellow illustrates how to skip parsing the header while reading a CSV document
String csvPath = "\home\user\document.csv";
CsvConfiguration skipHeaderConfig = new CsvConfiguration(){{
setSkipHeader(true);
}};
CsvDocument document = CsvDocument.read(csvPath, skipHeaderConfig);
The code bellow illustrates how to read a part of the columns that make up a document. In the example only the first and second column are parsed. The rest of them are ignored.
String csvPath = "\home\user\document.csv";
CsvConfiguration csvConfiguration= new CsvConfiguration(){{
setColumnIndexesToParse(0, 1);
}};
CsvDocument document = CsvDocument.read(csvPath, csvConfiguration);