2015-10-13 49 views
0

數據表中的列值分配期間獲得額外的字符,當我運行此代碼它不斷投入(及周邊'馬克。IronPython的變量保持在Spotfire

for column in dataTable.Columns: 
      a=a,column.RowValues.GetFormattedValue(row) 

a保持打印出來,因爲這

(('10/13/2015 '),' 桔子)

我怎樣才能使剛剛成立a =到這

10/13/2015Oranges


數據表建立

Date  |Fruit 
10/13/2015 |Oranges 
10/12/2015 |Apples 
+0

可以共享一些示例數據嗎? – niko

+0

@ niko增加了幾行 – Keng

回答

1

啊,其實我一直在尋找這個錯誤的方式。它不是Spotfire行爲,而是普通的Python行爲。

當你 ,串聯

,你實際上是形成一個元組。

要連接字符串,請改用+。下面的代碼工作,只要你喜歡:

from Spotfire.Dxp.Data import IndexSet 

dt = Document.Data.Tables["Data Table"] 

rc = dt.RowCount 
ix = IndexSet(rc, True) 
a="" 

for row in ix: 
    for column in dt.Columns: 
     a += column.RowValues.GetFormattedValue(row) 
    a += "\n" 

print a 

> 10/13/2015Oranges 
    10/12/2015Apples 

你可以在純Python的環境中複製此:

a = "foo", "bar" 
print(a) 

> ('foo', 'bar') 

b = "foo" + "bar" 
print(b) 

> foobar