jackson-dataformat-csv

How do I read tsv files with Jackson csv mapper?

為{幸葍}努か 提交于 2020-05-23 11:51:10
问题 I'm using the Jackson CSV lib to read CSV files. We've got the streaming example from the documentation : CsvMapper mapper = new CsvMapper(); mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); ObjectReader reader = mapper.readerFor(String[].class); MappingIterator<String[]> values = reader.readValues("/path/to/file") This works fine for CSV files. However I can't see how I can configure it to use tab instead of comma as the field delimiter, in order to read TSV files. The only config I can find

jackson-dataformat-csv: Mapping number value without POJO

☆樱花仙子☆ 提交于 2020-01-04 02:26:44
问题 I'm trying to parse a CSV file using jackson-dataformat-csv and I want to map the numeric column to the Number java type. CsvSchema schema = CsvSchema.builder().setUseHeader(true) .addColumn("firstName", CsvSchema.ColumnType.STRING) .addColumn("lastName", CsvSchema.ColumnType.STRING) .addColumn("age", CsvSchema.ColumnType.NUMBER) .build(); CsvMapper csvMapper = new CsvMapper(); MappingIterator<Map<String, Object>> mappingIterator = csvMapper .readerFor(Map.class) .with(schema) .readValues(is)

How do I serialize & deserialize CSV properly?

泄露秘密 提交于 2019-12-04 05:19:52
问题 I've been trying to serialize an object to a CSV String but the object contains a List and @JsonUnwrapped doesn't work on List objects. Expected sample output : color,part.name\n red,gearbox\n red,door\n red,bumper Actual output : com.fasterxml.jackson.core.JsonGenerationException: Unrecognized column 'name': Here is my code : (Most of it is the 2 POJO's) import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson

How do I serialize & deserialize CSV properly?

浪尽此生 提交于 2019-12-02 04:32:54
I've been trying to serialize an object to a CSV String but the object contains a List and @JsonUnwrapped doesn't work on List objects. Expected sample output : color,part.name\n red,gearbox\n red,door\n red,bumper Actual output : com.fasterxml.jackson.core.JsonGenerationException: Unrecognized column 'name': Here is my code : (Most of it is the 2 POJO's) import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml