I have CSV
file which I need to parse. The schema for this file is following:
name, contacts - where contacts are many strings for each person where the number of this contact columns is not regular.
For example:
john, john@wick.com, 123 123 123, fb/john.wick
mike, 123 0303 11
dave,
I'm trying to create a CsvSchema
with Jacskon CSV
for my bean:
public class Person {
private String name;
private String[] contacts;
}
By creating custom schema:
CsvSchema schema = CsvSchema.builder()
.addColumn("name")
.addArrayColumn("contacts", ",")
.build();
But I am getting this:
com.fasterxml.jackson.dataformat.csv.CsvMappingException: Too many entries: expected at most 2
How to with Jackson CSV
solve problem like that?
Java
code:
CsvMapper mapper = new CsvMapper();
CsvSchema schema = CsvSchema.builder()
.addColumn("name")
.addArrayColumn("contacts", ",")
.build();
MappingIterator<Person> it = mapper.readerFor(Person.class).with(schema)
.readValues(csvString);
List<Person> all = it.readAll();