简体   繁体   中英

Camel Bindy empty value represented as dot

I'm trying to unmarshal a csv file using Camel Bindy. The csv file has; as separator, the issue is that for empty values it contains a. character. So for example:

value1;value2;value3;value4;value5;value6
03/07/2020;value;.;value;.;.
.;.;0.5;.;value;5

With a pojo of for example:

@CsvRecord(separator = ";", skipFirstLine = true, quoting = true, generateHeaderColumns = true, skipField = true)
public class BindyTest {

    @DataField(pos = 1, columnName = "value1", required = true, trim = true,
            pattern = "dd/MM/yyyy")
    private LocalDate value1;

    @DataField(pos = 2, columnName = "value2", required = true)
    private String value2;

    @DataField(pos = 36, columnName = "value3", rounding = "HALF_UP",
            pattern = "#,###.##################", precision = 2)
    private BigDecimal value3;

    @DataField(pos = 4, columnName = "value4", required = true)
    private String value4;

    @DataField(pos = 5, columnName = "value5", required = true)
    private String value5;

    @DataField(pos = 6, columnName = "value6", required = true)
    private Integer value6;
}

Any suggestions on how to handle those. in the file before/during unmarshalling?

Thanks

I'm trying to unmarshal a csv file using Camel Bindy. The csv file has; as separator, the issue is that for empty values it contains a. character. So for example:

value1;value2;value3;value4;value5;value6
03/07/2020;value;.;value;.;.
.;.;0.5;.;value;5

With a pojo of for example:

@CsvRecord(separator = ";", skipFirstLine = true, quoting = true, generateHeaderColumns = true, skipField = true)
public class BindyTest {

    @DataField(pos = 1, columnName = "value1", required = true, trim = true,
            pattern = "dd/MM/yyyy")
    private LocalDate value1;

    @DataField(pos = 2, columnName = "value2", required = true)
    private String value2;

    @DataField(pos = 36, columnName = "value3", rounding = "HALF_UP",
            pattern = "#,###.##################", precision = 2)
    private BigDecimal value3;

    @DataField(pos = 4, columnName = "value4", required = true)
    private String value4;

    @DataField(pos = 5, columnName = "value5", required = true)
    private String value5;

    @DataField(pos = 6, columnName = "value6", required = true)
    private Integer value6;
}

Any suggestions on how to handle those. in the file before/during unmarshalling?

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM