Is there a built-in function in Apache CSV to ignore the header when reading csv?
Some time ago, we introduced a utility for converting CSV export files to SQL. For this, we chose Apache CSV. Everything has been fine so far, but now we have a change request.
All the CSV files that we process must contain headers, and now we must read these headers case insensitive, so our users do not need to make any effort to ensure that the CSVs they created comply with our header requirements.
Code example:
for (CSVRecord record : subsidiaryRows) {
String name = record.get(Data.NAME));
where Data.NAME
public static final String NAME = "Name";
And the problem clearly arises when the user uses the “name” as the column heading in his CSV instead of “Name” with a capital of “N”.
I followed the API and source, but did not find anything. Is there a way to get CSVRecord to use CaseInsensitiveMap to match it or something like that?
source
share