Loop Data
I can use this node when I want to iterate through a series of data for use, typically within the scope of the Loop Data
and Stop Loop
nodes. The data will be iterated sequentially if no additional configuration is set in the node.
The general expression used to access the list of data that this node is receiving is {{loopData.loopId}}
, where loopId
is a value that the user can customize.
Loop ID
The ID to identify the loop. Use this ID when I want to access loop data within an expression or fill it in the Stop Loop node.
Loop through
Table
Iterate through the data of a column in a table
Example
I will use the Loop Data
node to iterate through the values in the age
column.
First,
to iterate through the data in the column, I need to create columns in the table. Here, I will create two columns: age
and name
.
Next, I will insert data into those columns using the Insert Data
node.
Then, I will configure the Loop Data
node with the option to iterate by Table
.
Next, to retrieve the data for each iteration corresponding to the age
column, I will use the expression {{loopData.ZRGdfk.age}}
in the Press Key
node to output that value.
Finally, I will run the process to retrieve the values in the age
column for each iteration.
Numbers
Repeat an action or value using the selected counter.
Example
I will use the Loop Data
node to iterate through values using the counter
from 1
to 2
. First, I will configure the Loop Data
node with the option to iterate by counter, selecting to iterate from 1 to 2, meaning I will loop 2 times.
Calculating the number of iterations is simple. For example, iterating from 3
to 5
results in 3 iterations, calculated as (5-3)+1. Similarly, iterating from 2
to 6
results in (6-2)+1=5 iterations.
Next, configure the Press Key
node to type the text 123
for each iteration.
Finally, I will run this process.
Google Sheets
Iterate through data retrieved from the Google Sheets node. Each iteration retrieves data from a row in Google Sheets
.
- Connection Key: The key to connect to the
Google Sheets
node. This key name must match theReference Key (optional)
in theGoogle Sheets
node.
Example when using multiple random data in multiple iterations
I will use this in a process to comment multiple times on a video on YouTube
.
First, I will prepare a data sheet on Google Sheets
as follows:
Next, to retrieve data from Google Sheets
, I will configure the Google Sheets
node as follows:
Then, I will configure the Loop Data
node with the option to iterate by Google Sheets
. Here, I want to iterate twice to retrieve data, so I will set 2
in the Maximum number of iterations
field. I also want to retrieve data randomly, so I will select Random iteration order
.
Next, I will configure the Click element
node to click on the comment section.
Then, configure the Press Key
node with an expression to retrieve the value from the cmt
column for each iteration. Here, I will use the expression {{loopData.com.cmt}}
. Since I have already clicked on the comment section, I don’t need to specify a selector in this node.
Next, configure the Click element
node to click the Comment
button to post the typed comment.
Then, I will add a Delay
node for 1 second to continue commenting a second time.
Finally, I will configure the Stop Loop
node, where I will enter the same ID as in the Loop Data
node.
The node cluster will look like this:
When configuring the node cluster like this, the process will run from the Google Sheets
node to the Loop Data
node. After executing the series of nodes from Click element
to the Delay
node, the workflow will repeat based on the number specified in the Maximum number of iterations
field. I can understand that the process will repeat the nodes between the Loop Data
and Stop Loop
nodes for the selected number of times.
When running, the process will comment twice as desired.
Spreadsheet
Iterate through data retrieved from an Excel data file.
Example when retrieving multiple random values
I will use the Loop Data
node to retrieve random data from the fName
and lName
columns from an Excel file for use in the account registration process on w3schools
. I want the first name and last name to be retrieved randomly from a file.
First, I will prepare an Excel data file as follows:
Next, to retrieve data from the fName
column in that Excel file, I will configure the Spreadsheet
node as follows:
Then, I will configure the Loop Data
node with the option to iterate by Spreadsheet
.
Next, configure the Press Key
node with an expression to retrieve the value from the fName
column for each iteration. Here, I will use the expression {{loopData.fname.fName}}
.
Finally, I will configure the Stop Loop
node, where I will enter the same ID as in the Loop Data
node, and since I only want to input the value once and then exit the loop, I will check the Stop loop
box.
Next, to retrieve data from the lName
column in that Excel file, I will configure the Spreadsheet
node as follows:
Then, I will configure the Loop Data
node with the option to iterate by Spreadsheet
.
Next, configure the Press Key
node with an expression to retrieve the value from the lName
column for each iteration. Here, I will use the expression {{loopData.lName.ho}}
.
Finally, I will configure the Stop Loop
node, where I will enter the same ID as in the Loop Data
node, and since I only want to input the value once and then exit the loop, I will check the Stop loop
box.
The node cluster will look like this:
When running, the process has filled in random values from the ho
and ten
columns into the corresponding fields.
Variable
Iterate through the values of a variable when the variable is an array type.
Example
Here, I want to randomly comment multiple times on a video on YouTube
.
First, I will prepare a text file containing the list of comments I want to use.
Next, I will configure the Read File Text
node to retrieve the data and assign it to the cmt
variable.
Then, in the Loop Data
node, I will configure it to iterate over the cmt
variable, select Random iteration order
to retrieve random values from the variable for each iteration, and set Maximum number of iterations
to 2 to use the data twice.
Next, I will configure the Click element
node to click on the comment section.
Then, I will configure the Press Key
node to input the data retrieved for each iteration into the comment section using the expression {{loopData.cmt}}
. In this node, I don’t need to configure a selector since the Click element
node has already clicked on the comment section.
Next, configure the Click element
node to comment the typed text.
Then, add a Delay
node to pause for 1 second before continuing to comment again.
Finally, the Stop Loop
node. The node cluster will look like this:
When running the node cluster, the process has commented twice with random text each time.
Custom Data
When I select custom data, ensure that I write it in the form of an array of data using JSON syntax.
Example using the Loop Data
node to iterate through Custom Data
First, I will configure the Loop Data
node with the option to iterate through Custom Data
.
Next, I will input data by clicking the Insert Data
button, which will display a table. I need to paste the data I want to iterate into that table. Note that the data must be in array format. For example, I want to insert this data array:
["one", "two", 3, 4, { "name": "an" }]
Then setup node Press key
to write data json
above
Finally, the node cluster will look like this
have been output
Elements
When I select the Loop data
with Elements
option, this node will iterate through each element with a CSS Selector
matching the CSS Selector
I input.
Example
Here, I want to scrape the titles of videos available on a channel.
First, I will configure the Loop Data
node with the option to iterate through Elements
. To retrieve the titles of those videos, I need to input the common selector for the elements containing the video titles. Then, configure the number of titles to retrieve in the Max data to loop
field. I want to retrieve the first 2 titles sequentially, so I will not configure Random iteration order
.
Next, to retrieve the titles, I will use the Get Text
node to extract the text from each iterated element. In this node, instead of inputting the selector for the element containing the title, I only need to input the general expression {{loopData.vid}}
, which represents the element being iterated. Then, insert the retrieved value into the title
column created earlier. Each retrieved value will be inserted into a row in the column.
Then, I will use the Loop breakpoint
node to end the iteration here. The process will repeat the Export Data
node until it completes the 2 iterations I configured.
Finally, I will configure the Export Data
node to export the data inserted into the column to a file.
The node cluster will look like this:
When running this node cluster, the result I get is the list of retrieved titles.
The result in the file will be as follows:
Max data to loop (0 is loop all data)
Customize the maximum number of data items to iterate. The default is 0, which iterates through all data.
Start from index
Iterate from position 0, corresponding to the first position of the data in a list.
Reverse loop order
Iterate from the last element to the first element in the data list.
Random loop order
Retrieve an element in random order from the list.
See more: Looping
Note
Ensure the page does not reload when using this node, otherwise the node will encounter an error.