Nov 12 2014

Select DAT tutorial.

The Select DAT. TouchDesigner 088. 2014.
The Select DAT can function in two powerful ways. It can help you create specified selection sets from table DATs, and it can allow you to reference DATs as instances.

1
00:00:00,500 –> 00:00:04,067
Let’s examine the select DAT.

2
00:00:04,067 –> 00:00:15,100
The select DAT chooses a subset
of rows and columns from the
input table DAT based on
specific search criteria.

3
00:00:15,100 –> 00:00:23,733
The select DAT has several
options for defining that search
or extraction criteria.

4
00:00:23,733 –> 00:00:31,267
In this example we will select
the range of rows based on the
name of the row.

5
00:00:31,267 –> 00:00:35,700
The first entry in a row is
considered its name.

6
00:00:35,700 –> 00:00:36,633

7
00:00:36,633 –> 00:00:45,533
In this example we will select
our rows by name, and we will
select our column subset by
index.

8
00:00:45,533 –> 00:00:53,500
The index is the numerical
identification value of the row
or column, starting with 0.

9
00:00:53,500 –> 00:01:02,800
If we extract a range of columns
starting with column index 1, we
will effectively delete column
0.

10
00:01:02,800 –> 00:01:09,733
The columns in “table2” are
indexed in the numerical range 0
to 5.

11
00:01:09,733 –> 00:01:18,433
In the parameters panel, we can
enter values by typing them in
directly, or by using the
slider.

12
00:01:18,433 –> 00:01:25,367
We can also use Python to create
expressions that will generate
numerical values.

13
00:01:25,367 –> 00:01:33,300
The Python expression will
automatically be evaluated, and
in this case, produce a
numerical result.

14
00:01:33,300 –> 00:01:47,700
In this example, “me” is the DAT
named “select2”, “inputs[0]” is
the DAT named “table2”, and
“numCols” is the number of
columns in “table2”.

15
00:01:47,700 –> 00:01:57,833
Even though we use a base 0
numbering system to index the
number of columns or rows, there
are 6 total columns, not 5.

16
00:01:57,833 –> 00:02:04,333
We subtract 1 from the total row
count to generate our desired
index.

17
00:02:04,333 –> 00:02:06,800

18
00:02:06,800 –> 00:02:16,700
We can click the “edit” button
on the parameters panel of a
text DAT to launch our default
text editor.

19
00:02:16,700 –> 00:02:25,167
Any changes we make and save in
the text editor will
automatically be updated in
Touch Designer.

20
00:02:25,167 –> 00:02:34,767
We can also press the “viewer
active” button on the bottom
right of the operator, to type
changes directly into the
operator.

21
00:02:34,767 –> 00:02:45,900
The text editor will launch with
a temporary file, so it’s
important to keep track of
changes made in either the text
editor, or directly in the
operator.

22
00:02:45,900 –> 00:02:53,733
In this example we convert our
text DAT to a table, by using
the convert DAT.

23
00:02:53,733 –> 00:03:04,000
The “split cells” option defines
which character Touch Designer
will use create new cells from
the incoming text DAT.

24
00:03:04,000 –> 00:03:12,100
As with any operator, we can
middle mouse click on the
operator to display information
about that node.

25
00:03:12,100 –> 00:03:13,367

26
00:03:13,367 –> 00:03:19,433
We’ve converted our text to a
table, now we feed that into a
select DAT.

27
00:03:19,433 –> 00:03:20,533

28
00:03:20,533 –> 00:03:25,367
We’ve chosen to extract our rows
by selected values.

29
00:03:25,367 –> 00:03:26,733

30
00:03:26,733 –> 00:03:34,167
The first entry in each row is
the value or string we will need
to search for.

31
00:03:34,167 –> 00:03:36,100

32
00:03:36,100 –> 00:03:43,433
We can separate string entries
by a “space” character to search
for multiple patterns.

33
00:03:43,433 –> 00:03:52,267
The select DAT will extract each
row from the incoming table that
matches the search pattern.

34
00:03:52,267 –> 00:03:57,667
Now we will extract our columns
by selected values.

35
00:03:57,667 –> 00:04:05,433
Again, the first value in each
column is the value or string we
will need to search for.

36
00:04:05,433 –> 00:04:06,800

37
00:04:06,800 –> 00:04:14,733
In this example we will use
Python expressions to create our
search and extraction criteria.

38
00:04:14,733 –> 00:04:21,600
I’ve included some links so you
can learn more about Python
regular expressions.

39
00:04:21,600 –> 00:04:23,700
We start with a text DAT.

40
00:04:23,700 –> 00:04:29,867
As you can see, I’ve capitalized
each occurrence of the letter
“M”.

41
00:04:29,867 –> 00:04:37,000
We wire the text DAT to a
convert DAT, to convert the text
into a table.

42
00:04:37,000 –> 00:04:41,700
We use the “space” character as
our split cell value.

43
00:04:41,700 –> 00:04:44,267

44
00:04:44,267 –> 00:04:53,500
We wire the convert DAT to our
select DAT, and we choose to
extract our rows by selected
condition.

45
00:04:53,500 –> 00:04:56,367

46
00:04:56,367 –> 00:05:05,533
We use a Python regular
expression to create our search
criteria, in this case the
capitalized letter M.

47
00:05:05,533 –> 00:05:08,433

48
00:05:08,433 –> 00:05:23,433
We use the “str.search” method
which will search for every
occurrence of the capitalized M
in every cell of our input table
DAT.

49
00:05:23,433 –> 00:05:29,200
We’ve extracted every row that
contains the string capital M.

50
00:05:29,200 –> 00:05:30,133

51
00:05:30,133 –> 00:05:42,067
In its default settings, the
selected DAT extracts only the
rows whose first cell contains
the letter M.

52
00:05:42,067 –> 00:05:50,967
We can easily change this
default setting, by adjusting
the “from column” parameter.

53
00:05:50,967 –> 00:06:00,833
We can search a specific column
to find cells that contain our
search string, then extract that
entire row.

54
00:06:00,833 –> 00:06:04,333

55
00:06:04,333 –> 00:06:11,667
In this example we search for
the value “5” in our input table
DAT.

56
00:06:11,667 –> 00:06:20,300
We search column 0, and for each
cell that contains the character
5, we extract that entire row.

57
00:06:20,300 –> 00:06:23,667
Now let’s extract some specific
columns.

58
00:06:23,667 –> 00:06:28,367
Let’s take a look at the
“str.match” method.

59
00:06:28,367 –> 00:06:33,067
The “match” method is different
than the “search” method.

60
00:06:33,067 –> 00:06:39,567
The “match” method only
evaluates the first character of
the input cell.

61
00:06:39,567 –> 00:06:45,033
With the match method, the input
cell “34” will evaluate FALSE.

62
00:06:45,033 –> 00:06:50,733
The search method evaluates all
the characters of the input
cell.

63
00:06:50,733 –> 00:06:57,900
When we search for the 3
character, we find two
conditions that evaluate TRUE.

64
00:06:57,900 –> 00:07:05,533
When we match for the 3
character, we also find two
conditions that evaluate TRUE.

65
00:07:05,533 –> 00:07:07,533