CSV File Reader Input Adapter Sample

Introduction

This sample demonstrates a StreamBase application that processes financial tick data from three financial feeds. The application determines the fastest of the three feeds, computes useful statistics for each feed, and calculates the VWAP for the incoming tick data.

This sample's application is a variation of the FeedProc sample included in the StreamBase distribution. In the FeedProc example, there are three input streams fed by a feed simulation. By contrast, this sample uses three CSV Reader embedded adapters in place of the three input streams. Refer to FeedProc Sample for more information on the application itself.

You can use the Java dequeuer program FeedProcGUI, provided as part of the FeedProc sample, to view the output from this sample. To do so, you must have the FeedProc sample loaded as a project in Studio, alongside this sample.

The CSV Reader adapter and the sbfeedsim command share some characteristics. They both essentially read records from a CSV file and turn them into tuples. The CSV Reader runs in the same process space as the StreamBase application, while sbfeedsim runs as a separate process. Each of these approaches might be preferred under different circumstances.

Running This Sample in StreamBase Studio

  1. In the Package Explorer, double-click to open the feedproc.sbapp application. Make sure the application is the currently active tab in the EventFlow Editor.

  2. Click the Run button. This opens the SB Test/Debug perspective and starts the application.

  3. Input streams are automatically fed by three instances of the CSV File Reader adapter. Output is displayed in the Application Output view, while error messages are displayed in the Console view.

  4. Optional. Run the output viewer from the FeedProc sample. Open the Run History list as described in the FeedProc sample's documentation, and select the FeedProcGUI launcher. This runs the FeedProc.java program, which opens a separate window with title FeedProc Sample, and connects to the StreamBase Server instance running feedproc.sbapp.

  5. When done, press F9 or click the Stop Running Application button.

Running This Sample in Terminal Windows

This section describes how to run the sample in UNIX terminal windows or Windows command prompt windows. On Windows, be sure to use the StreamBase Command Prompt from the Start menu as described in the Test/Debug Guide, not the default command prompt.

  1. Open two terminal windows on UNIX, or two StreamBase Command Prompts on Windows. In each window, navigate to your workspace copy of the sample, as described above.

  2. In window 1, launch StreamBase Server running feedproc.sbapp:

    sbd feedproc.sbapp

  3. In window 2, run a dequeuer:

    sbc deq

    You can optionally run separate dequeuers in separate windows:

    sbc deq ITview

    sbc deq Traderview

  4. To stop the sample, run sbadmin shutdown.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top menu, select FileLoad StreamBase Sample.

  • In the search field, type csv file to narrow the list of samples.

  • Select CSV file input adapter from the StreamBase Standard Adapters category.

  • Click OK.

StreamBase Studio creates a single project containing the sample files.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

StreamBase Systems strongly recommends that you load this sample in Studio, and use the workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids the permission problems that are inevitable when trying to work with the installed location in C:\Program Files or /opt/streambase. The default workspace location for this sample is:

studio-workspace/sample_adapter_embedded_csvreader

See Default Installation Directories for the location of studio-workspace on your system.

In the default StreamBase installation, this sample's files are installed in:

streambase-install-dir/sample/adapter/embedded/csvreader

See Default Installation Directories for the location of streambase-install-dir on your system. This location usually requires administrator privileges for write access.