Jump to content
  • How to assign a list to Spotfire® document property using IronPython


    This article shows how to assign a list to Spotfire® document property using IronPython

    Introduction

    Sometimes it is necessary to store lists in a document property to use it further in a Python or Java script, say for marking or filtering. Out of the box there is no "List" data type available in the document properties, so we can use a string document property instead to store the comma separated list and convert it back to "List".

    Code Sample

     # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.  
     
     #Store the comma separated values as a string value in the document property 
     mylist = ['Jan', 'Feb', 'March'] 
     delimiter = "," 
     Document.Properties["mylist"] = delimiter.join(mylist) 
     print Document.Properties["mylist"]  
     
     #Retrieve back the list when needed 
     listprop = Document.Properties["mylist"] 
     delimiter = "," 
     mylist = listprop .split() 
     print my_list  
     
     #Note - Integer and date values need to be converted into string format and then converted into their original data types when retrieving them back  
     
     #eg:- When storing integer values-  
     
     #Store- 
     Document.Properties["myintlist"] = delimiter.join(str(i) for i in my_list)  
     
     #Retrieve- 
     mylist = [int(i) for i in myintlist.split()] 
     

     

    References

    License: TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...