I am trying to write code in which the contents of csv are converted to bean. This is what my code looks like
final String TEMPLATE_FILE="addresses.csv"; CSVReader template = new CSVReader(new FileReader(TEMPLATE_FILE)); String [] header = template.readNext(); ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); strat.setType(PersonEx.class); strat.setColumnMapping(header); CsvToBean csv = new CsvToBean(); List list = csv.parse(strat, template);
Here, if the PersonEx.class attribute is missing in csvHeader, this attribute is set to null. Is there a way I can ignore this and only create the bean values present in the header?
source share