Spotfire® Automation Services User Guide

Batch editing multiple analysis files

You can create an Automation Services job that performs a set of tasks in multiple analysis files. This example shows how you can set up a job that loops through a list of analysis files defined in a ForEach task, opens each analysis, executes an IronPython script, and then saves the analysis.

The job consists of the following tasks:

ForEach

The ForEach task contains the table with the list of analysis files to iterate over. In this example, the table has only one column, Path, that specifies the location of the analysis in the library.

If you want the job to continue even if it fails for one analysis in the list, clear the check box End job if a task fails.

Tip: To get the path of multiple analyses in your library, you can use Tools > Library administration.
  1. In the Library Administration dialog, use the search bar to find the analyses of interest. For example, to narrow your search down to only analysis files, you can use the term type:dxp. See Searching the library .
  2. Select the analyses and then right-click in the table. In the drop-down menu, select Copy Selected as Table.

Result: A semicolon-separated table is copied to the clipboard. It contains various details about each analysis, including the library path. You can paste the table into the Embedded table field in the ForEach task.

Open Analysis from Library

This task opens the analysis from the library. To get the analysis library path from the ForEach task, we use the property {forEachProperty:[Column]} in the Path field, where [Column] is the column name in the table:

{forEachProperty:Path}

Tip: To easily select columns from the ForEach task table, you can use Tools > Insert Field.

Execute Script

The Execute Script task contains some IronPython script to run in the opened analysis. The script calls the Spotfire API to make changes in the file. The type of changes that are possible are limited by what is exposed in the Spotfire API. Some examples include:
  • Updating images in text areas.
  • Updating scripts using IronPython to a newer IronPython version.
  • Finding all occurrences of JavaScript scripts in text areas that reference the Spotfire JQueryUI library, and modifying them to embed the JQueryUI library in the analysis.

To learn more about how to use IronPython in Spotfire, and the capabilities of the Spotfire API, see:

Save Analysis to Library

This task saves the opened analysis to the library, with the changes performed by the script. To save the analysis to the same location, we again use the we use the property {forEachProperty:[Column]} in the Path field:

{forEachProperty:Path}