Skip to content

Publishing and Receiving CSV Events via Files

Purpose

This application demonstrates how to configure WSO2 Integrator: SI Tooling to Publish and receive data events processed within Siddhi to files in CSV default format.

Prerequisites

  • Edit the uri <SI-Tooling-Home>/samples/artifacts/CSVMappingWithFile/new/example.csv by replacing <SI-Tooling-Home> with the absolute path of your SI Tooling home directory.

  • You can also change the path for file.uri in the sink, if you want to publish your event file to a different location.

  • Save this sample. If there is no syntax error, the following messages would be shown on the console:

    • CSVDefaultMapping.siddhi successfully deployed.

Executing & testing the Sample

  1. Start the Siddhi application by clicking on 'Run'.
  2. If the Siddhi application starts successfully, the following messages are shown on the console:
    • CSVDefaultMapping.siddhi - Started Successfully!

Viewing the results

  • Source takes input from the <SI-Tooling-Home>/samples/artifacts/CSVMappingWithFile/new/example.csv then produce the event. example.csv has data in below format.

    1,WSO2,23.5
    2,IBM,2.5

  • Sink takes input from source output and produces the output to outputOfCustom.csv in CSV custom format.outputOfCustom.csv's data appear in below format.

    1,WSO2,100.0
    2,IBM,2.5

@App:name("CSVDefaultMapping")
@App:description('Publish and receive data events processed within Siddhi to files in CSV default format.')

@source(type='file',
dir.uri='file://<SI-Tooling-Home>/samples/artifacts/CSVMappingWithFile/new',
action.after.process='NONE',
@map(type='csv'))
define stream InputStream (id int, name string, amount double);

@sink(type='file', file.uri='/<SI-Tooling-Home>/samples/artifacts/CSVMappingWithFile/new/outputOfDefault.csv' , @map(type='csv'))
define stream OutputStream (id int, name string, amount double);

from InputStream
select *
insert into OutputStream;