Arrays 在Iron Python中将数组转换为字符串
我对Iron Phyton非常陌生,我正在尝试创建一个脚本,允许用户在下拉列表中选择“All”函数。这是我目前掌握的代码,但我收到一条错误消息,指出属性值的“type”System.String[]”与预期的“System.String”类型不匹配 我在Spotfire中编码,我不能在属性中存储数组,因为只允许字符串。我搜索到我可以使用“,”。join(我的列表) 但我只是不知道放在哪里…请帮忙,谢谢…代码如下Arrays 在Iron Python中将数组转换为字符串,arrays,ironpython,spotfire,Arrays,Ironpython,Spotfire,我对Iron Phyton非常陌生,我正在尝试创建一个脚本,允许用户在下拉列表中选择“All”函数。这是我目前掌握的代码,但我收到一条错误消息,指出属性值的“type”System.String[]”与预期的“System.String”类型不匹配 我在Spotfire中编码,我不能在属性中存储数组,因为只允许字符串。我搜索到我可以使用“,”。join(我的列表) 但我只是不知道放在哪里…请帮忙,谢谢…代码如下 from System import Array from Spotfire.Dxp
from System import Array
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import DataValueCursor
#Get access to the Column from which we want to get the values from
myCol = Document.ActiveDataTableReference.Columns["Business Group"]
rowCount = Document.ActiveDataTableReference.RowCount
rowsToInclude = IndexSet(rowCount,True)
#Create a cursor to the Column we wish to get the values from
cursor1 = DataValueCursor.CreateFormatted(Document.ActiveDataTableReference.Columns ["BusinessGroup"])
strArray = Array.CreateInstance(str,rowCount)
#Loop through all rows, retrieve value for specific column, and add value into array
for row in Document.ActiveDataTableReference.GetRows(rowsToInclude,cursor1):
rowIndex = row.Index
value1 = cursor1.CurrentValue
strArray[rowIndex-1] = value1
#Set property to array created above
myCol.Properties.SetProperty("BusinessGroup",strArray)
假设您的代码在代码段的最后一行失败,因为“BusinessGroup”应该是一个字符串而不是字符串数组,您可以使用以下方式连接:
myCol.Properties.SetProperty("BusinessGroup", ', '.join(strArray))