public static <T> List<T> getCsvData(String file, Class<T> clazz) throws IOException {
try (FileReader fr = new FileReader(file)) {
HeaderColumnNameMappingStrategy<T> strategy = new HeaderColumnNameMappingStrategy<>();
strategy.setType(clazz);
CsvToBean<T> csvToBean = new CsvToBeanBuilder<T>(fr)
.withSeparator(';')
.withQuoteChar('\'')
.withIgnoreQuotations(true)
.withMappingStrategy(strategy).build();
return csvToBean.parse();
}
}
I use CsvToBean to convert a csv file into a bean. The csv file uses a semicolon as a separator. When a column value in the file contains a semicolon, it will fail to parse. Is there any way to solve it?
elample 'aa;a';'bbb';