Apama Documentation : Connecting Apama Applications to External Components : Standard IAF Plug-ins : The File IAF Adapter (JMultiFileTransport) : Opening comma separated values (CSV) files
Opening comma separated values (CSV) files
An example of defining an OpenFileForReading event that opens a CSV file so that each field is automatically parsed appears below. The additional data required by the CSV codec is stored in the payload dictionary.
com.apama.file.OpenFileForReading openCSVFileRead :=
new com.apama.file.OpenFileForReading;
 
//matches transport in IAF config
openCSVFileRead.transportName := JMultiFileTransport;
 
//the request id to use
openCSVFileRead.requestId := integer.getUnique();
 
//read using JCSVCodec
openCSVFileRead.codec := "JCSVCodec";
 
//file to read
openCSVFileRead.filename := "/usr/home/formby/stocktick.csv";
 
//separator char is a ","
openCSVFileRead.payload["separator"] := ",";
 
//emit event to channel in config.
emit openCSVFileRead to "FILE";
Subsequently, when the File adapter receives FileLine events, the adapter stores each field in the data sequence in order. You can access the ones you are interested in.
For details about using the CSV codec, see The CSV codec IAF plug-in.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback