Contents
This sample demonstrates the usage of the embedded CSV File Writer adapter.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, click → .
-
Select this sample from the Embedded Adapters list.
-
Click OK.
StreamBase Studio creates a single project containing the sample files.
By default, the sample files are installed in:
- On Windows
-
C:\Program Files\StreamBase Systems\StreamBase.n.m\sample\adapter\embedded\csvwriter\ - On UNIX
-
/opt/streambase/sample/adapter/embedded/csvwriter/
When you load the sample into StreamBase Studio, Studio copies the sample project's
files to your Studio workspace. StreamBase Systems recommends that you use the
workspace copy of the sample, especially on UNIX, where you may not have write access
to /opt/streambase. In the default installation, the
path to this sample in your Studio workspace is:
UNIX: ~/streambase-studio-n.m-workspace/sample_adapter_embedded_cvswriter Windows XP: C:\Documents and Settings\username\My Documents\StreamBase Studion.mWorkspace\ sample_adapter_embedded_cvswriter Windows 7 and Windows Vista: C:\Users\username\Documents\StreamBase Studion.mWorkspace\ sample_adapter_embedded_cvswriter
-
In the Package Explorer, double-click to open the
CVSWriterTest.sbappapplication. Make sure the application is the currently active tab in the EventFlow Editor. -
In the canvas, select the CSVWriter adapter named OutputAdapter1. In the Properties view, Adapter Settings tab, change File Name to point to a valid location on your machine. The sample's default file name,
sample.csv, will be written to the sample project directory. -
Click the
Run button. This opens the SB
Test/Debug perspective and starts the application.
-
Select the Manual Input tab.
-
Enter the value
10for a and press . -
Press F9 or click the
Stop Running Application button.
-
The file specified in the File Name field should now contain tuples formatted as shown in this example:
a,b,ts 10,100,2009-05-30 22:48:44.502-0400
If you used the default output file name, or specified another file written to the sample project directory, you might have to select the project name in the Package Explorer and press F5 to refresh the project's contents before the output file appears.
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.
-
Open two terminal windows on UNIX, or two StreamBase Command Prompts on Windows. In each window, navigate to the directory where the sample is installed, or to your workspace copy of the sample, as described above.
-
In window 1, run
sbd CSVWriterTest.sbapp. -
In window 2, run
sbc enqueue InputStream1 < inputstream.dat -
In window 2, run
sbadmin shutdownto shut down the server. -
Look for the file
sample.csvin the current directory.
