Skip to main content
Version: 2.17.x.x LTS

CSVDataSource

The CSVDataSource reads records from a CSV file. The column names must be either configured within the DataSource configuration or they can be read from the CSV file's first line. The entries can be trimmed from whitespace if requested. Empty columns are set to null.

Configuration

NameType, usage constraints, defaultsDescription
filenamerequired: paraVal
default: none
type: path to readable CSV file
Name of the CSV file which is used as the record source.
attributesoptional: paraList
default: none
type: list of strings
Defines the column names of the CSV file. If defined, the CSV file must start with a data record. The column names may not be contained in the CSV file. If attributes is not defined, the CSV file must contain the column names in the first line of the CSV file.
separatoroptional: paraVal
default: ,
type: char
Separator character used as delimiter for separating entries.
quotecharoptional: paraVal
default: "
type: char
Quoting character used for quoted elements.
trimoptional: paraVal
default: false
type: boolean
The entries are trimmed from whitespace if this parameter is set to true.
encodingoptional: paraVal
default: default encoding
type: string
The name of the character set that should be used to to decode the file. The available values depend on the version and vendor of the JVM. Examples: UTF-8, ISO-8859-1, UTF-16LE

Example

<dataSource type="CSVDataSource">
<dp:paraVal name="filename" value="etc/csv.in"/>
<dp:paraVal name="separator" value=";" type="char"/>
<dp:paraVal name="quotechar" value="\t" type="char"/>
<dp:paraList name="attributes">
<value>firstname</value>
<value>lastname</value>
<value>email</value>
</dp:paraList>
</dataSource>