Search code examples
scriptingironpythonspotfire

I have a list stored as string in IronPython, Spotfire. How do I retrieve it back in the original list format?


A list is stored in the form of string in Document.Properties in Spotfire using IronPython script since Document.Properties doesn't directly support list type.

Saving into Document property to use it in other scripts

mylist = ['13','24','57'] print mylist

['13','24','57']

Document.Properties["mylist"] = str(mylist)

Retrieving the list stored in the form of string

This is where I need help. I need to access each element in the list.


Solution

  • You can use ",".join(str(x) for x in mylist) to convert a list to string.

    mylist = ['13','24','57']
    print(",".join(str(x) for x in mylist))
    >>>>13,24,57
    

    Also Document Properties can accept a list. The document property simply needs to be a multi-select rather than a string.