0

I have a CSV that has a few file header lines at top. The rest of the rows are in the normal tablular format. Is it possible to parse the header row or process it differently from the remainder of the normal tabular data?

Jawad
  • 193
  • 1
  • 8

1 Answers1

1

You can Get the headers separately quite simple. headers are in line no 1, which makes it simple to fetch them. here is an example:

listReader = new CsvListReader(new FileReader(CSV_FILENAME), CsvPreference.STANDARD_PREFERENCE);
final CellProcessor[] processors = getProcessors();
List<Object> customerList;
while( (customerList = listReader.read(processors)) != null ) {
                        System.out.println(String.format("lineNo=%s, rowNo=%s, customerList=%s", listReader.getLineNumber(),                listReader.getRowNumber(), customerList));

if(listReader.getRowNumber()==1)
{
// do what ever you need with the headers...
}
Yaniv Levy
  • 78
  • 10