Search in sources :

Example 1 with ColumnPositionMappingStrategy

use of au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy in project the-app by devops-dojo.

the class AbstractCsvReader method parseCsv.

public List<T> parseCsv() throws IOException {
    ClassPathResource classPathResource = new ClassPathResource(getClassPathFilePath(), this.getClass().getClassLoader());
    InputStreamReader ioReader = new InputStreamReader(classPathResource.getInputStream(), "UTF-8");
    CSVReader reader = new CSVReader(ioReader, ';');
    ColumnPositionMappingStrategy<T> strat = new ColumnPositionMappingStrategy<>();
    strat.setType(getDestinationClass());
    strat.setColumnMapping(getColumnMapping());
    CsvToBean<T> csv = getParser();
    return csv.parse(strat, reader);
}
Also used : ColumnPositionMappingStrategy(au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy) InputStreamReader(java.io.InputStreamReader) CSVReader(au.com.bytecode.opencsv.CSVReader) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

CSVReader (au.com.bytecode.opencsv.CSVReader)1 ColumnPositionMappingStrategy (au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy)1 InputStreamReader (java.io.InputStreamReader)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1