Business Intelligence Tools / Developers Corner

Basics of Implementing IronPython in Spotfire

Over the last few weeks, I’ve released several posts on learning IronPython.  
The response has been extremely positive. Many users identify with the struggle to learn IronPython (and other languages) for Spotfire. One individual reached out to say that he needed more information on where/how to apply the code. I realized I’ve written that post for TERR, but I haven’t for IronPython. So, this post will explain implementing IronPython code. Let’s get to it.

Where do you put the code?

So, you found an IronPython code snippet to apply in your own DXP, but you don’t know where it goes. Perhaps, you found something on Brock’s website.
Now, unlike TERR scripts, IronPython scripts don’t run automatically. They must be triggered, usually by a button or a property control, which live in text areas. Therefore, IronPython scripts start in text areas. So, add a text area and follow the instructions below.
  1. First, add text area.
  2. Right-click and select Edit HTML. You can also select Edit Text Area.
  3. Then, click the insert action control button in the toolbar. 
  4. You’ll then need to decide whether you want to click on a Button, Link or Image. Buttons are most common. Make a selection in the Control type drop down.
  5. Give it a name in the Display text input box.
  6. Now, click on the Script button on the left hand side of the dialog.
  7. This opens a new dialog where you want to click New. 
  8. Name the script.
  9. Copy and paste the script in the script window.   Make any modifications as needed.
  10. Add any required parameters. 
  11. Finally, click Run Script to make sure it works.
  12. Click Ok.
If needed, you may edit the script from the text area going thru similar steps. Or, IronPython scripts can also be edited from the Edit — Document Properties menu. 

What about Python modules?

The same user who requested this post also asked if he needed to install anything to use IronPython. He was thinking about how users install R or TERR packages to run TERR scripts. You don’t need to install anything, although you can. There are TIBCO Community posts on how to install custom python modules if you want to use your own or other modules like numpy or pandas. You can find those here and here. If you are reading this, you probably aren’t that far along.  But that’s okay!  There’s plenty to learn.  This should get you started implementing IronPython in your own DXPs.

Spotfire Version

Content created with Spotfire 7.12.

4 thoughts on “Basics of Implementing IronPython in Spotfire

  1. Atheer Attar Reply

    I use TERR a lot to do complex data cleaning, transformation. My knowledge in R helped a lot. I wish they make the support for GGPLOT more mature, that way a whole new level of visualization will be unlocked.

  2. Pingback: Exploring the Spotfire API with IronPython » The Analytics Corner

  3. Pingback: IronPython For Loops with Spotfire API » The Analytics Corner

Leave a Reply

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