Sreelekshmy Selvin
Sreelekshmy Selvin

Reputation: 81

How to get the length of a record from a csv file?

I am using org.apache.commons.csv to read a csv file. My code looks like this

Iterable<CSVRecord> records = CSVFormat.RFC4180.withIgnoreEmptyLines(true)
                                               .parse((Reader)arg0.getReader());

for (CSVRecord record : records) {

}

How to get the comma seperated string value from each record ?

Upvotes: 3

Views: 1710

Answers (2)

Sreelekshmy Selvin
Sreelekshmy Selvin

Reputation: 81

for (CSVRecord record : records) {

currentRecordSize = record.size();

// code

}

Upvotes: 1

azro
azro

Reputation: 54168

You may use size() and get(int index) methods

for (CSVRecord record : records) {
    for(int i=0; i<record.size(); i++){
        System.out.println(record.get(i));
    }
}

All the detailled doc is here.

Upvotes: 1

Related Questions