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.

11 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

  4. Anivar Melaya Reply

    Thank you for the explanation. Is there a way we could trigger action control button click automatically when switching from one sheet to another? Basically, to trigger an IronPython script. I used to do it with JS, but since the the version 10.3.3, this is no longer feasible. Thank you.

  5. Pele Reply

    Hi, Julie
    I have a problem, i insert text are and edit html for need activate other page. I can’t do it and i beginner study in spotfire Coding.
    Please help me..
    exam this html
    Go to Page 2

    then i can’t continue it. T_T

  6. Julie Sebby Reply

    If you are trying to insert a link or a button that will allow the user to navigate to another page, just add an action control. It’s a button in the toolbar when you are editing HTML or editing the text area. Then you can inspect the HTML and see how it was written.

  7. Camilo Castillo Reply

    Hi Julie, I would like to know if have you ever worked with well patterns in spotfire, I am trying to compute Np (Cummulative production) for specifics patterns but adding a column with the pattern name will not work because some patterns share producer wells. I have already tried Sum(OIL) Over (Intersect(Pattern),AllPrevious(Date)) but did not work because some patterns share producer wells. Do you have an idea of this?

    • Julie Sebby Post authorReply

      What about creating a new column that is a concatenation of the pattern and the producer well name to create a unique value. Then reference this new column in the intersect. WOuld that work?

  8. Jackie Reply

    Hi Julie! I currently have an iPython script action control button that reloads my data (uploaded from an Excel file) that works perfectly in the desktop version, but does not work on the web version. Do you have any workarounds for this issue? A big thanks in advance!

Leave a Reply

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