ConvertFixRecordToCsvPreParser

Configuration file

./conf/samples/sample_split_fix2csv.xml

Class name

com.ebd.hub.datawizard.parser.ConvertFixRecordToCsvPreParser

Description


This preparser transforms a fix record file into a CSV file (only one line is kept in the main memory at any given time).

The preparser expects an XML configuration file (see example below). The following parameters can be used.


config

Element

Superordinate element of the XML configuration file.

length

Attribute of element config

Lines of the fix record file are expected to be separated by line breaks for attribute value -1. Positive integer values describe the length of the line.

delim

Attribute of element config

The delimiter that is used in the created CSV file.

segment

Element

For each record type in the fix record file, there has to be an XML element segment that describes the fields.

matchcode

Attribute of element segment

Can be empty (all lines match) or specifies, if not empty, the match code like "Starts with" does in nodes (e.g. matchcode="123" ). Alternatively, a regular expression can be specified (e.g. matchcode="regex:123.*").

insert

Attribute of element segment

Is optional and can fill a new first column in the CSV file with a constant. The attribute can, for example, be used to insert a match code in CSV lines.

column

Sub-element of element segment

Describes a field of the record type specified in the superordinate element segment. The order of the column elements is considered.

length

Attribute of element column

The length of the field in the record type (line).

trim

Attribute of element column

true or false. Specifies if leading or trailing whitespaces in the fix record field shall be removed in the CSV field.

type

Attribute of element column

Specifies the data type of the CSV field (as in target field attribute Type in the GUI). Values can be Integer, Float, Double, String, Date, Timestamp, BigInt, or BigDecimal.

format

Attribute of element column

Specifies the format of the CSV field (as in target field attribute Template in the GUI).

Example


We want to transform the fix record line


001Hello world 110915


into the CSV line


A;1;Hello World;2015-09-11


This can be achieved with the following XML configuration file:


<?xml version="1.0" encoding="ISO-8859-1"?>
<config length="-1" delim=";">
<segment matchcode="" insert="A">
<column length="3" trim="false" type="Integer" />
<column length="12" trim="true" type="String"/>
<column length="6" trim="false" type="Date" format="ddMMyy" />
</segment>
</config>


Note: Notice the type cast from String "001" to Integer "1" and String "110915" to Date "2015-09-11", as it would be done in mappings.

Example file in roll-out


sample_split_fix2csv.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- length = -1: new line is used. Otherwise define length of record
delim: which delimiter should be used
-->
<config length="-1" delim=";">
<!-- matchcode: check if line 'starts with' or use regular expression by matchcode="regex:...."
insert: if not empty, this value will be added as first column
-->
<segment matchcode="" insert="A">
<column length="10" trim="true" type="String" />
<column length="10" trim="false" type="String" format="" />
<column length="2" trim="false" type="Integer" format="" />
<column length="2" trim="false" type="Integer" format="N6.2" />
<column length="8" trim="false" type="Date" format="ddMMyyyy" />
</segment>
</config>