The CSV codec plug-in
The CSV codec plug-in (
JCSVCodec) translates between comma separated value (CSV) data and a sequence of string values. This codec (or the Fixed Width codec plug-in) can be used with the standard Apama File adapter to read data from files and to write data to files. (For more information on the Fixed Width codec, see
The Fixed Width codec plug-in; for more information on the standard Apama File adapter, see
Apama File adapter.)
CSV format is a simple way to store data on a value by value basis. Consider an example CSV file that contains stock tick data. The lines in the file are ordered by Symbol, Exchange, Current Price, Day High, and Day Low, as follows:
TSCO, L, 395.50, 401.5, 386.25
MKS, L, 225.25, 240.75, 210.25
In this example, each field is separated from the next by a comma. You can use other characters as separators as long as you identify the separator character for the CSV codec.
To specify a separator character other than a comma, do one of the following:
Set the
separator property in the IAF configuration file that you use to start the File adapter. For example:
<property name="separator" value=" " />
If you set the separator property, the codec uses the separator you specify by default. If you do not specify the separator property, and the codec does not receive any configuration events before receiving messages to encode or decode, the codec refuses to process messages. The codec throws an exception back to the module that called it, which is either the transport or the semantic mapper depending on whether the data is flowing downstream or upstream.
For an example configuration file, see adapters\config\JCSVCodec-example.xml.dist in the Apama installation directory. The JCSVCodec-example.xml.dist file itself should not be modified, but you can copy relevant sections of the XML code, modify the code as required for the purposes of your data, and then add the modified content to the adapter configuration file in which the codec is to be used.
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.