简体   繁体   中英

Spotfire: Call a data function from IronPython and update a column with the results

I am using an IronPython script to call a Data Function. The result of the function is a Column, and I would like to update the column in place with the results (similar to the 'Replace columns on update' option on the output parameters page when running the data function manually.)

This looks to me like I should be using this method to add the output parameter: I way to do this would be something like this: Spotfire API: SetColumnsOutput(OutputParameter, ColumnsOutputBuilder)

Then in the ColumnsOutputBuilder I would set the AddNewColumnsWhenUpdating to False.

However, when I do that, it keeps adding a new column to the table anyway. I tried with True and get the same behavior. Below is the code for generating the output parameter. Can anyone help me identify why the column is always being added instead of updating?

def set_outputs(output_collection):
  output_table_name = get_datatable_name()
  output_builder = OutputParameterBuilder("CorrelationCoefficient", ParameterType.Column)
  output_param = output_builder.Build()

  found, output_table = data_manager.Tables.TryGetValue(output_table_name)

  if found:
    output_column_builder = ColumnsOutputBuilder(output_table)
    output_column_builder.AddNewColumnsWhenUpdating = False
    output_collection.SetColumnsOutput(output_param, output_column_builder)
  else:
    print('The results datatable {table} could not be found!'.format(table=output_table_name))

Re-added as answer: If the column is already defined in the data function, you can simply call the data function via Execute. You don't need to define the new column in Iron Python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM