Sunday, July 24, 2016

Inet Source Operator

Objective

In my first stream program with infosphere, I read from a URL. In infosphere to do this, there is an operator called InetSourceOperator.

Stream processing language file will look like below.



namespace eduwatch;
use com.ibm.streamsx.inet::InetSource ;

composite Main {
type StockQuote = tuple<rstring name,rstring ticker,int64 volume,float64 previous,
float64 change,float64 dayHigh,float64 dayLow,float64 peRatio,float64 pegRatio>;
graph
stream<rstring rawQuote> DjiaRaw = InetSource()
{
param
URIList : [
"http://download.finance.yahoo.com/d/quotes.csv?s=pg+ko+AAPL+goog&f=nsvpclghrr5&e=.csv"
];
incrementalFetch: false;
fetchInterval : 7.0;
punctPerFetch: true;
() as rawQuote = FileSink(DjiaRaw)
{
param 
file : "rawQuote.csv"; format : csv;
writePunctuations: true; flush: 1u;
}


}



Sample Output

Punctuation received: WindowMarker
"\"Procter & Gamble Company (The) \",\"pg\",6165618,85.26,\"+0.46 - +0.54%\",\"4:00pm - <b>85.72</b>\",85.45,85.98,27.02,4.01"
"\"Coca-Cola Company (The) Common \",\"ko\",8836148,45.45,\"+0.38 - +0.84%\",\"4:00pm - <b>45.83</b>\",45.46,45.84,27.59,5.25"
"\"Apple Inc.\",\"AAPL\",28313669,99.43,\"-0.77 - -0.77%\",\"4:00pm - <b>98.66</b>\",98.31,99.30,10.98,1.30"
"\"Alphabet Inc.\",\"goog\",1259823,738.63,\"+4.11 - +0.56%\",\"4:00pm - <b>742.74</b>\",736.56,743.24,30.22,1.29"
""
Punctuation received: WindowMarker
"\"Procter & Gamble Company (The) \",\"pg\",6165618,85.26,\"+0.46 - +0.54%\",\"4:00pm - <b>85.72</b>\",85.45,85.98,27.02,4.01"
"\"Coca-Cola Company (The) Common \",\"ko\",8836148,45.45,\"+0.38 - +0.84%\",\"4:00pm - <b>45.83</b>\",45.46,45.84,27.59,5.25"
"\"Apple Inc.\",\"AAPL\",28313669,99.43,\"-0.77 - -0.77%\",\"4:00pm - <b>98.66</b>\",98.31,99.30,10.98,1.30"
"\"Alphabet Inc.\",\"goog\",1259823,738.63,\"+4.11 - +0.56%\",\"4:00pm - <b>742.74</b>\",736.56,743.24,30.22,1.29"
""
Punctuation received: WindowMarker
"\"Procter & Gamble Company (The) \",\"pg\",6165618,85.26,\"+0.46 - +0.54%\",\"4:00pm - <b>85.72</b>\",85.45,85.98,27.02,4.01"

Reference

No comments:

Post a Comment