1

when I run this code it keeps putting in ( and surrounding ' marks.

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

a keeps printing out as this

(('10/13/2015'),'Oranges')

How can I make it just set a=to this

10/13/2015Oranges


Data Table setup

Date        |Fruit
10/13/2015  |Oranges
10/12/2015  |Apples
Keng
  • 52,011
  • 32
  • 81
  • 111

1 Answers1

2

ah, actually I was looking at this the wrong way. it's not a Spotfire behavior but a normal Python one.

when you concatenate with ,, you are actually forming a tuple.

to concat strings, use + instead. the following code works as you like:

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

you can replicate this in a purely Pythonic environment:

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

> ('foo', 'bar')

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

> foobar
niko
  • 3,946
  • 12
  • 26