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();


this worked for me

try (Reader in = new FileReader(f);
                CSVParser parser = new CSVParser(in,
                        CSVFormat.EXCEL.withDelimiter(';').withHeader("Assembly Item Number", "Material Type",                              "Item Name", "Drawing Num", "Document Type", "Revision", "Status", "Drawing name",
                                "BOM Material Type", "Component Name"));) {
            for (CSVRecord record : parser) {
                    System.out.println(record.get("Item Name"));
            }
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }