No header mapping was specified, the record values can’t be accessed by name (Apache Commons CSV)

Calling withHeader() to the default Excel CSV format worked for me:

CSVFormat.EXCEL.withHeader().parse(in);

The sample in the documentation is not very clear, but you can found it here
:
Referencing columns safely:
If your source contains a header record, you can simplify your code and safely reference columns, by using withHeader(String…) with no arguments:
CSVFormat.EXCEL.withHeader();

Leave a Comment