Stuck trying to get a simple list of values from a DAT's column

image

I’ve got a simple DAT here. I’d like to use a bisect python function on it, but to do that, I need the values in a simple list.

If I use datname.col('trigger'), it returns this kinda thing

and I don’t know how to use list comprehension or whatever to just get the values to use with bisect. I think I just need a list that’s [5,6,7,8,9,10,12]

Help me Obi Touch Kenobi.

Those are cells not values, so here is the magic formula:

theListYouWant = [cell.val for cell in datname.col(‘trigger’)[1:]]

Getting cell.val pulls the actual value. The [1:] starts at the second entry to skip the header.

2 Likes

Thanks Ivan - I need to start getting comfortable with loops :slight_smile:

By the way, for cell in < is the cell in there just a name made up for the loop, or is it an actual object/type that’s inside the datname.col list?

It is just a variable name, but I use that one because it is in fact a Cell object, which is why you need to get the “.val” of it. I’m a firm believer in descriptive variable names!

1 Like

Simply getting a list of strings from a set of row(s) or column(s) of a DAT table has been an ugly python expression, but in an upcoming TouchDesigner build, it will be easy with val=True in DAT.row(rowNumName, val=True) for .row(), .col(), ,rows(), .cols(), cell(), cells().

2 Likes

@greg Did this ever come true? :pleading_face: :pleading_face: :pleading_face:

Hi @Peeet,

if not mistaken it’s in the latest Experimental release. Documentation forthcoming…

cheers
Markus

1 Like