Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.9.0
-
None
-
None
Description
If you try to parse a file like this:
name$value a$1 b$0 c$3
with a CSVFormat defined like this:
CSVFormat.DEFAULT.builder()
.setRecordSeparator("$")
.setHeader()
.build();
and then try to retrieve a field by name with:
record.get("name")
i get the following error:
java.lang.IllegalArgumentException: Mapping for name not found, expected one of [name$value]
at org.apache.commons.csv.CSVRecord.get(CSVRecord.java:121)
Looks like the parser does not consider the separator when auto detects headers.
If I modify the source file using comma as separator and
format.setRecordSeparator(",")
it works.