Appending rows in a table with a row from another table

Hello,

This is definitely a newbie question in regards to appending tables. I’m doing fine running a script to append a table with blank row (n=op(“table1”), n.appendRow()) , but what is the syntax to grab the data from a row in another table?

Any help would be greatly appreciated!

-Adam

If you want to grab a single row:

r = op(‘table1’).row[5] for example, or
r = op(‘table1’).row[‘Month’]

This will return a list of Cell objects that can then be accessed.

op(“table1”).appendRow( op(“table1”).row[5] ) might be an example of what you’re looking for.

You can also copy an entire table with the .copy() method.

Following two sections should help clarify:

derivative.ca/wiki088/index. … e_Contents
derivative.ca/wiki088/index. … e_Contents

Cheers,
Rob.

Thanks Rob, that did the trick!

Hi, I cant seem to get this syntax right,
I want to append a row to a table from another table

select4 being the source and table4 being the destination.

Im using :

op(‘table4’).appendRow(op(‘select4’).row[1])

but the error I get is:

“builtin_function_or_method object is not subscriptable”

any ideas?

This is close - row is a method:

So while you wrote this:

op('table4').appendRow(op('select4').row[1])

You want this:

op('table4').appendRow(op('select4').row(1))

The problem this will produce, however, is that you’ll get the entire cell object copied into your target table. Really, you need to make a list of the contents of the cells in the source row so you can correctly append your target table. That would look like this:

op( 'target' ).appendRow( [ op( 'source' ).row(0)[ x ] for x in range( op( 'source' ).numCols ) ] )
1 Like