Python reference for largest value in table

Hi everyone, TD newbie here.

I have a list of integers in a Table DAT, and I want to be able to select the largest one and send it to a DAT null. I’m guessing there’s a simple line of Python for this but I can’t seem to work it out.

Thanks!

Hi!

The Python expression should be something like this :

o = op('table1')
max_value = max(int(r[0].val, 10) for r in o.rows())

It’s pretty easy to use into a Constant CHOP, but I’m not sure how to do it into a DAT.

Would a sort DAT followed by a select DAT of the first row not work for you? This would probably perform better since it will run in C++ under the hood instead of using python to convert all of the string data to integers prior to sorting.

Thanks for both suggestions. I hadn’t thought of the Sort DAT + Select - it’s obvious when you stop and think…!