03-15-2017 12:19 AM
I have a requirement where in I need to read the data from a csv file and push it into SAS Event Stream Processing.
For that I have written a python code which reads each row per 5 seconds and prints the data.
Now I need to push each row per 5 second to SAS Event Stream Processing.I am unable to figure out to how to achieve the same.
Your help and guidance is highly appreciated.
Thanks in advance
04-25-2017 11:45 AM
You have a couple options here. You can read the csv directly into ESP using a file/socket connector or adapter. This example shows how to configure a csv connector in ESP Studio: CSV Connector with ESP Studio
If you are modeling in the XML layer then the csv connector would look something like this:
<connectors> <connector name="New_Connector_1" class="fs"> <properties> <property name="type"><![CDATA[pub]]></property> <property name="fsname"><![CDATA[trades1M.csv]]></property> <property name="fstype"><![CDATA[csv]]></property> <property name="transactional"><![CDATA[true]]></property> <property name="blocksize"><![CDATA]></property> <property name="dateformat"><![CDATA[%Y-%m-%d %H:%M:%S]]></property> </properties> </connector>
Additionally, you can open a socket and write to the socket from the Python program and have ESP listen to that socket. You would do this by defining fsname to be the address of the socket to listen to (for example, localhost:40000).
Finally, there is a Python publish/subscribe API with ESP 4.1 This would allow you to publish to ESP directly from the python program. I've attached a sample program to help you get started