Reputation: 312
I am trying to use the Apache CSV library to work with CSV files from another company. Sometimes the header line and other lines have trailing commas. The header also has a variable set of fields. If I use CSVParser to parse the header, it throws an exception because of the duplicate (empty) column headers created from the trailing commas. If I parse the header line manually, I am not sure how to supply the column names to the parser. It accepts an Enum, ResultSet artifacts or specific String values, but not a List, Collection or Iterable. Is there a solution that lets me use CSVParser and column titles?
Upvotes: 0
Views: 480
Reputation: 1097
You need to set the below parameter to true.
withAllowMissingColumnNames(true)
API is here. And make sure you are using version 1.1 or greater. Looks like this was fixed as part of a bug
Upvotes: 1