...
Parameter name | type | Info |
---|---|---|
separator | string | mandatory - can be ',' or ';' or 'anything' |
skipFirstLine | boolean | optional - default value = false - allow to skip the first line of the CSV file |
|
| This annotation is associated to the root class of the model and must be declared one time. |
case 1 : separator = ','
The separator used to segregate the fields in the CSV record is ',' :
...
Code Block |
---|
@CsvRecord( separator = "," ) public Class Order { ... } |
case 2 : separator = ';'
Compare to the previous cae, the separator here is ';' instead of ',' :
...
Code Block |
---|
@CsvRecord( separator = ";" ) public Class Order { ... } |
case 3 : separator & skipfirstline
The feature is interesting when the client wants to have in the first line of the file, the name of the data fields :
...
Parameter name | type | Info |
---|---|---|
int | pos | mandatory - digit number |
pattern | string | optional - default value = "" - will be used to format Decimal, Date, ... |
length | int | optional - digit number - represents the length of the field for fixed length format |
precision | int | optional - digit number - represents the precision to be used when the Decimal number will be formatted/parsed |
case 1 : position
This parameter represents the position of the field in the csv record
...
Code Block |
---|
public class Client { @DataField(pos = 1) private String clientNr; @DataField(pos = 2) private String firstName; @DataField(pos = 3) private String lastName; ... } |
case 2 : pattern
The pattern allows to enrich the format of your data
Code Block |
---|
@CsvRecord(separator = ",") public class Order { @DataField(pos = 0) private int orderNr; @Link private Client client; @DataField(pos = 4) private String isinCode; @DataField(name = "Name", pos = 5) private String instrumentName; @DataField(pos = 6, precision = 2) private BigDecimal amount; @DataField(pos = 7) private String currency; @DataField(pos = 8, pattern = "dd-MM-yyyy") -- pattern private Date orderDate; ... } |
case 3 : precision
The precision is helpful when you want to define the decimal part of your number
...