I'm using SuperCSV to parse a CSV file. It works flawlessly. The CSV file I'm passing may contain some invalid records in it. At that time, is it possible to log which line is not processed?
List<InputBean> csvContentsList = new ArrayList<InputBean>();
ICsvBeanReader beanReader = new CsvBeanReader(fileReader, CsvPreference.STANDARD_PREFERENCE);
InputBean bean = null;
do {
try {
bean = beanReader.read(InputBean.class, header, getProcessors());
if (bean != null)
csvContentsList.add(bean);
} catch (Exception e) {
logger.error("Error in parsing the record:"+e.getMessage());
}
} while (bean != null);
In this code, if the CSV file contains invalid record, it throws an error and it is caught in the catch block. How could be print that invalid record? or the line number of it ?