Contents
This sample demonstrates the use of the Spotfire Streaming CSV File Writer output adapter.
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, click
> . -
Enter
csv writer
to narrow the list of options. -
Select CSV file writer output Adapter from the StreamBase Standard Adapters category.
-
Click
.
StreamBase Studio creates a project for the sample.
-
In the Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves after a minute, select the project, right-click, and select
> from the context menu. -
Open the
src/main/configurations
folder and double-click to opensbengine.conf
. -
Use a dataAreaPath property to specify the full, absolute path to a folder that is to contain the file to be written by this adapter. You can uncomment the dataAreaPath line appropriate for your operating system and edit the
sbuser
placeholder name for your system login name. For example, take the following starting point:streamBase = { // dataAreaPath = "C:/Users/sbuser/Documents" // dataAreaPath = "/Users/sbuser/Documents" // dataAreaPath = "/home/sbuser/Documents" // dataAreaPath = "/Users/sbuser/tmp" }
Uncomment the first dataAreaPath line and replace
sbuser
:streamBase = { dataAreaPath = "C:/Users/
your-login-name
/Documents" // dataAreaPath = "/Users/sbuser/Documents" // dataAreaPath = "/home/sbuser/Documents" // dataAreaPath = "/Users/sbuser/tmp" } -
Open the
src/main/eventflow/
folder.packageName
-
Open the
CSVWriterTest.sbapp
file and click the Run button. This opens the SB Test/Debug perspective and starts the module. -
Select the Manual Input tab.
-
In the Stream drop-down control, select the
Write
stream. -
Enter any integer value such as
10
in the num field and click . -
Enter several more integers, clicking
after each one. -
Use your operating system's file browser to navigate to the folder you specified in step 3. A file named
sample.csv
(or named as specified in the File Name field of the adapter's Properties view, File Creation tab) should now contain tuples formatted as shown in this example:num,square,Timestamp 10,100,2018-04-27 12:40:42.912-0400 200,40000,2018-04-27 12:40:50.958-0400 42,1764,2018-04-27 12:40:56.958-0400
The sample is configured to append to the specified file, so you may also see lines from previous runs of this sample.
-
In the Manual Input tab, select the Stream drop-down control, and select the
zStartControl
stream. Enter the name of an alternate file for this adapter to write to. For example, enterNewFileName.csv
. -
In the Stream control, re-select the
Write
stream and enqueue a few more integers in the num field. -
Use your operating system's file browser to locate and open the
NewFileName.csv
file in the same directory you specified in step 3. Open the file to see the most recent set of tuples entered. -
When done, press F9 or click the Terminate EventFlow Fragment button.
If you do not edit the sbengine.conf
file to specify a
write location, the adapter writes its output file to a default location in the
module's node directory.
Navigate down the following folder sequence to find the default location:
-
Studio workspace folder
-
.nodes
(This is a hidden folder on macOS.) -
nodename
(see the Clusters view to identify the node name for this sample's most recent launch) -
fragments
-
enginename
(see the Clusters view) -
engine-data-area
You can identify the default write location using the Engine
Data Area line of the engine properties for the current node in the Clusters
view. This property shows the full path to the parent folder of the engine-data-area
folder.
Remember that the node directory is normally removed on successful stopping and removal of a node. The node directories for all nodes that Studio starts are removed when Studio exits, if the nodes completed successfully. The node directories for nodes that ended with an error condition are preserved.
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
Load this sample in StreamBase® Studio, and thereafter use the Studio 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 permission problems. The default workspace location for this sample is:
studio-workspace
/sample_adapter_embedded_csvwriter
See Default Installation
Directories for the default location of studio-workspace
on your system.