Jump to content
  • How to stream data from a CSV file with Spotfire Data Streams into a Spotfire visualization


    Here's a way simulate live streaming data from an existing data set. Let's take the simplest case: you have a data set stored in a CSV file, and you want to treat each successive row of that file as a streamed event.

    Introduction

    Here's a way simulate live streaming data from an existing data set. Let's take the simplest case: you have a data set stored in a CSV file, and you want to treat each successive row of that file as a streamed event.

    Solution

    Before following the steps below, make sure you first

     Install TIBCO Spotfire Data Streams (you may use TIBCO Streaming or TIBCO Live Datamart, instead): quick start instructions for Microsoft Windows.

    1. Startup StreamBase Studio and navigate to the Authoring Perspective.

    2. From the Studio menu bar, select Connectivity Wizard....

    converted-file.png.71d3e6b143e7c4c64dcf605f59587a45.png

    3. In the Connectivity Wizard dialog, leave the Create New Project radio button selected and click the Next button.

    converted-file.png.537df620a32834d2147a54b9f01419f0.png

    4. On the Select a Source dialog screen, click the radio button for StreamBase Feed Simulation and click the Next button

    converted-file.png.79e714155756e9816887676fb75bb7f4.png

    5. In the Select a Data File wizard screen, click the Browse... button, select your csv data file (tempdata.csv in this case), make sure (just for demo purposes) that the Automatically restart simulation when complete checkbox is checked, and click Next

    imag1.png.d22469113f784e40ef1c0214805aedb2.png

    This dataset tempdata.csv is 100 rows that might be readings from ten different thermometers measuring human body temperatures, but it is a file I quickly created using. The sample data I used is attached here as tempdata.txt; it's free to be used; just rename to tempdata.csv after downloading.

    6. In the Configure the Table screen, for this demo, ensure that Time-series selected.

    image2.png.45290559d05900ffd9be6a5445bfdaf7.png

    Because we are looping the data from the data file, we want to create a unique key for each event, even as the data is repeated by looping. Your data may already have a natural primary key, and you may not want to loop, so you may make different choices.

    7. Click Get Schema from Data Source to populate the schema of the LiveView data table the wizard will create, and click Next

    image3.png.4a023af6586caa5b901991315e540873.png

    8. On the Data Retention screen, click Next to accept a default 60 minute data retention period.

    image4.png.841d2865b13253a7d6cd98fac53fe3d6.png

    This option is of course something to set based on the characteristics of your own data set. LiveView data always resides in memory, so you want to always be sure not have an infinitely growing table and therefore eventually get the dreaded OutOfMemoryError. Definitely ballpark the math. For this example, at 10 events per second, that's 36000 events per 60 minutes and at maybe 50 bytes per event, in an hour we're only going to accumulate less than 2MB of table data, which we can easily accommodate with the server's default heap allocation of 3GB.

    9. On the Add Server Authentication screen, accept the Allow any connections to the server default value, and click Next.

    image5.png.8a4d0cd016cc7bda22435acfad27ab5d.png

    10. On the Summary screen, enter Project Name sensors, and Table Name temperatures, and click Finish.

    image6.png.38869074e5d2b9000a3d77d06a31210b.png

    The wizard will now create a LiveView fragment and application project. This may take some time.

    11. On the Project Creation Successful screen, you can either Close or Start Server....

    For this demo, choose to start the server.

    12. Once the server is started, click Close.

    13. Next, use Spotfire Desktop or Analyst 10.x and above and start it up.

    (Currently, on the Spotfire Web Player, Streaming data requires a WebSocket connection to perform well. You might be unable to interact with visualizations, and data updates could become irregular. If the WebSocket connection fails, the application will use a fallback mechanism, resulting in a suboptimal experience.)

    14. Click Connect to

    image7.png.4e429ff6332921bad369c3c509316762.png

    15. Scroll to TIBCO Spotfire Data Streams

    image8.png.326c226c49a1f708353a76bda6413fe8.png

    16. Select New Connection

    image9.png.bc06cc6eda3e57467e8bcbeb64e27db2.png

    17. In the TIBCO Spotfire Data Streams dialog, enter:

    Server: localhost:10080

    And click the Connect button

    image10.png.613cf8c2ad9f157f346c32754aede299.png

    18. In the Views in Connection dialog, under Available tables in database select user > temperatures and click the Add button. Under Views in connectiontemperatures will appear:

    19. Click the OK button

    image11.png.e54dd4e72d53fb442e2fb8d046b23507.png

    20. On the Add Data to Analysis screen, observe that temperatures is displayed and press the OK button

    image12.png.6f527c6757a00a1e7afb95ab474e3645.png

    21. On the Your data is ready! screen click Start from visualizations

    image13.png.49d05e52c7d36f5c7500c65d6fd993e8.png

    22. Under Visualization Types, click Table

    converted-file.png.a4e1937890b3bdea35e78e7f0abe56b8.png

    23. At this point you will see a basic table visualization that's updating as the simulated sensor data streams into Spotfire.

    converted-file.png.a76b6f038e9f836c7e42fee10fe5e141.png

    Then you can make other Spotfire visualizations as you wish.

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...