FasterXML / FasterXML/jackson-dataformats-text
Support parsing CSV with header regardless of unknown columns
- Dominant language
- Java
- Stars
- 455
- Forks
- 164
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 2
Description
When reading given CSV with _jackson-dataformat-csv_ 2.11.4
```
name,weight,age
Roger,69,27
Chris,89,53
```
using following snippet
```
CsvMapper csvMapper = new CsvMapper();
CsvSchema csvSchema = CsvSchema.builder().setUseHeader(true)
.addColumn("name").addColumn("age").build();
List persons = csvMapper
.readerFor(Person.class)
.with(csvSchema)
. readValues(csv)
.readAll();
...
class Person {
public String name;
public int age;
}
```
a _CsvMappingException_ is thrown (_Too many entries: expected at most 2_) because the column _weight_ is not known to CsvSchema.
`csvMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);` still leads to the same _CsvMappingException_.
Thus please introduce a new _CsvParser_ feature e.g. `IGNORE_UNKNOWN_COLUMNS` (disabled by default) that allows reading CSV regardless of unknown columns.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.