Skip to Main Content
Spotfire Ideas Portal
Status Already exists
Product Spotfire
Categories Scripting
Created by Guest
Created on Mar 1, 2023

Ability to convert a String or Real to a SingleReal using IronPython

Currently it's not possible to convert a String or Real to Single Real using IronPython to set the value to a document property of type SingleReal. It's doable using Spotfire data function. But we would like to have it also on IronPython.


Reference :

DataType Class (tibco.com)

DataType.SingleReal Field (tibco.com)

  • ADMIN RESPONSE
    Mar 23, 2023

    When assigning values to document properties from IronPython scripts, Spotfire automatically tries to convert a string to the target type, e.g. SingleReal. So, the following should work in your case:

    value = 1.234 # float value in Python
    Document.Properties["mysinglerealproperty"] = str(value)

  • Attach files
  • Guest
    Reply
    |
    Apr 27, 2023

    Hi Magnus

    Yes, it worked.

    Thanks for help very much! .. This request can be closed.

  • Admin
    Magnus Rylander
    Reply
    |
    Mar 15, 2023

    Hi Anas, thanks for the clarification.

    Spotfire automatically tries to convert a string to the target type, e.g. SingleReal. So, the following should work in your case:

    value = 1.234 # float value in Python
    Document.Properties["mysinglerealproperty"] = str(value)

  • Admin
    Magnus Rylander
    Reply
    |
    Mar 14, 2023

    Hi Anas, Thanks for contribution. Not sure I understand the context, but wouldnät it be possible to use general conversion functions in Python, e.g. float(value)?

    1 reply