Advanced CSV

A CSV template is defined with a *.csv.properties file. This properties gives you options to change general configuration, define format or provide custom validation.

The available options are:

Key Default Description
charsetName UTF-8 Option to change the charset name.
quote « The quote character is used when a cell contains special characters, such as the delimiter char, a quote char, or spans multiple lines.
separator ; The delimiter character separates each cell in a row.
endOfLine \n The end of line symbols to use when writing.
showHeader true If true, show the column headers.
columns N/A Mandatory. List of the model fields to render.
xxxx.name N/A Header name to write. If the name property is not present the header will be the field name
xxxx.type String Available types are «date», «boolean», «int»,«double», «long», «bigdecimal».
xxxx.format N/A Used to format date, boolean and number (ex: birthdate.format=dd/MM/yyyy). For the boolean type you can specify how to write true or false values by two comma separated values: married.format=Yes,No.
xxxx.notNull false Is used to define if the field is optional or not.
xxxx.unique false Is used to define the field must be unique.

Example

# General configuration
quote="
separator=;
endOfLine=\n
charsetName=UTF-8
columns=customerNo, firstName, lastName, birthDate, mailingAddress, married, numberOfKids, favouriteQuote, email, loyaltyPoints

# customerNo (must be unique)
customerNo.name=ID
customerNo.nullable=false
customerNo.unique=true

# firstName
firstName.name=First name
firstName.nullable=false

# lastName
lastName.name=Last name
lastName.nullable=false

# birthDate
birthDate.name=Birth date
birthDate.nullable=false
birthDate.type=date
birthDate.format=dd/MM/yyyy

# mailingAddress
mailingAddress.name=Mailling address
mailingAddress.nullable=false

# married
married.name=Married
married.nullable=true
married.type=boolean
married.format=Yes,No

# numberOfKids
numberOfKids.name=Number of kids
numberOfKids.nullable=true

# favouriteQuote
favouriteQuote.name=Favorite quote
favouriteQuote.nullable=false

# email
email.name=Email
email.nullable=false

# loyaltyPoints
loyaltyPoints.name=Loyalty points
loyaltyPoints.nullable=false
   

On this page


Edit this page