Business Intelligence Tools / Developers Corner

Quickly Generating Data Tables from User Input

Sometimes in Spotfire I want to generate a quick/small table that contains user input rather than storing it in a bunch of document properties. There’s a nice, quick way to do this using TERR.

I just made a simple data function that takes two parameters:

  • Colnames – String of column names separated by commas
  • DataText – A comma delimited (csv format) data to feed the table

The data function returns a DataTable called “Result”.

In the TERR code, we concatenate the column names and data and read it in as a csv file directly to a R data frame. Spotfire naturally translates this to a data table when it is returned.

You could add some error catching to protect against bad inputs, but here is simple set of code:

lines = paste(Colnames,"\n", DataText)
conn = textConnection(lines)
Result = read.csv(conn)

All we have to do is run this whenever the inputs change (basically whenever we change the DataText input) and it automatically updates the resulting table.

To populate the table, you could either expose a text area for direct input by the user or you could generate it in IronPython whenever a document property changes. For instance, you could concatenate several document properties into a result table, which would then be used to feed a visualization or be used in a subsequent data function.

You could also create a table through IronPython, but this is a nice way to have it run asynchronously and smoothly. Plus, you could do some extra magic in the TERR function if that was needed in the workflow.

Happy Spotfiring!

If you want to download this example, we have it hosted on

6 thoughts on “Quickly Generating Data Tables from User Input

  1. shrikanth haravi Reply

    Hi Troy,

    Request you to explain in detail on the above video to create the visualization, which is more useful any clinical review.


  2. Anmol Reply

    Hi Troy,

    Thank you for sharing this insightful article. I had a couple of questions:
    1. Does this whole workflow require TERR to be installed?
    2. You have connected a textbox to a SF data table. IS the reverse true? Can i set it up so that my html table gets populated on the basis of the data that is inside the data table. I want to enable selective editing of data.
    3. ANy idea if this binding works at the template level only or will it work on the webplayer as well?

    Thank you

  3. Troy Ruths Post authorReply

    Hey Anmol-
    Glad you like the article!
    1. This requires TERR to be installed/enabled. For the desktop client, this isn’t an issue but may need some configuration on the web player.
    2. You can go the other way around and populate a document property from what’s in a table. You would just send in the filtered/marked data and you could write some R code to turn it into HTML or text.
    3. To get this to work on the web player, you’d need a TERR engine enabled. This requires a Stats Server running with a TERR engine.


  4. Alex Johnstone Reply

    The first item in the list seems to have a space in front of it – cat in the file is ” cat”. It doesn’t seem to matter as Spotfire ignores this, but it’s off putting. Is there a way to stop this?

  5. Jaap Reply

    Hi Troy,
    I have used this approach to allow users to add their own data points to the visualization. This has worked perfectly from 2016 until this week.
    Now for some reason I get an error in the webplayer about the read.csv function.
    It does still work in the spotfirevedito though.

Leave a Reply

Your email address will not be published. Required fields are marked *