Python/Jython lists to results table

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Python/Jython lists to results table

Andreas Rzepecki
Hello together,

in my current plugin for Fiji I filled three python/jython lists with several values.

e.g.:

a_list = [1, 2, 3]
b_list = [1, 2, 3]
c_list = [1, 2, 3]

Now I tried to print this into a results table (with columns a, b, c). Using the addValue() command leads to: "2nd arg can't be coerced to String" while using Array.show() macro leads to: "type object 'java.lang.reflect.Array' has no attribute 'show'". At the moment I am a bit confused. Do I have to use the addValue() command with iteration through every object of the lists or is there a better way to do this? Thank you in advance.

Best regards

Andreas

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Python/Jython lists to results table

Pariksheet Nanda
On 10/26/2013 01:30 PM, Andreas Rzepecki wrote:

> in my current plugin for Fiji I filled three python/jython lists with
> several values.
>
> e.g.:
>
> a_list = [1, 2, 3]
> b_list = [1, 2, 3]
> c_list = [1, 2, 3]
>
> Now I tried to print this into a results table (with columns a, b,
> c). Using the addValue() command leads to: "2nd arg can't be coerced
> to String" while using Array.show() macro leads to: "type object
> 'java.lang.reflect.Array' has no attribute 'show'". At the moment I
> am a bit confused. Do I have to use the addValue() command with
> iteration through every object of the lists or is there a better way
> to do this? Thank you in advance.
>

Maybe addValue() is being passed the list directly instead of a string
or number value?  The code below works for me:


a_list = [1, 2, 3]
b_list = [1, 2, 3]
c_list = [1, 2, 3]

table = ResultsTable()

for i in range(len(a_list)):
        table.incrementCounter()
        table.addValue('A', a_list[i])
        table.addValue('B', b_list[i])
        table.addValue('C', c_list[i])

table.show('Results')


> Andreas

Pariksheet

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html