# Loop Operations

##

{% hint style="info" %}
Looping functionality will work on the datasets which were created by loading files into RDA and/or via logical dataset creation from other datasets.
{% endhint %}

## 1. Timed loop&#x20;

Step 1: Create an empty **timed\_loop\_example\_1** using AIOps studio as shown in the below screenshot

![Empty pipeline ](/files/-MgCdHqQVASyX86DiOAc)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.

\
*`###### Pipeline for timed loop: Sleeps 'interval' seconds after each iteration.`*\
*`###### if the max_iterations is specified, loop will stop after max_iterations reached`*\
*`###### each iteration as variable loop_index set (starts at 0 and increments by 1)`*\
\
*`@c:timed-loop interval = '3' & max_iterations = 10`*\
&#x20;   *`--> @dm:empty`*\
&#x20;   *`--> @dm:addrow message = "This is row number ${loop_index}"`*\
&#x20;   *`--> @dm:save name = "temp-df-${loop_index}"`*\
\
*`--> @c:new-block`*\
&#x20;   *`--> @dm:concat names = "temp-df-.*"`*<br>

![Pipeline code added for timed loop example](/files/-MgCfYvRaVGStapYvqm1)

Step &#x33;**:** Click verify button to verify the pipeline. RDA will verify the pipeline without any errors (as shown below)

![Loop pipeline code is verified for syntax errors as shown in above screenshot](/files/-MgCgJgtdXOSHA6WwBzk)

Step &#x34;**:** Click execute button to execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Screenshot-1 ](/files/-MgCh9WG8lTpVqbcU2Ym)

RDA executes a looping-based pipeline and prints the loop details as shown in the above screenshot. During each iteration/loop, the pipeline screen updates the iteration number as shown in the above screenshot.

![Screenshot-2](/files/-MgChdIXlJ3N_KShH2Ev)

After iterating through max\_iterations, pipeline data is stored in output and exits.

Step 5: Verify the data after the timed loop operation is completed as shown in the below screenshot (data is printed for 10 iterations in this example).

![Output is printed after max\_iterations as shown in the above screenshot.](/files/-MgCjIXf3OGZOYe3nMDn)

## 2. Count loop

&#x20;Step 1: Create an empty **count\_loop\_example\_1** using AIOps studio as shown in the below screenshot.

![Empty pipeline](/files/-MgIJELmxShP-jidq8en)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.

\
*`###### Pipeline for count loop: starts with 'start' number and increment by using`*\
*`###### 'increment' until the value is greater then equal to 'end' variable`*\
*`###### value for the each iteration is set as 'loop_index'`* \
\
*`@c:count-loop start = 0 & end = 10 & increment = 1`*\
&#x20;   *`--> @dm:empty`*\
&#x20;   *`--> @dm:addrow message = "This is row number ${loop_index}"`*\
&#x20;   *`--> @dm:save name = "temp-df-${loop_index}"`*\
&#x20;   *`--> @c:new-block`*\
&#x20;   *`--> @dm:concat names = "temp-df-.*"`*<br>

![Pipeline code is added to loop count pipeline example](/files/-MgIKTQCAxIC13bGV_ke)

Step &#x33;**:** Click verify button to verify the pipeline. RDA will verify the pipeline without any errors (as shown below)

![Loop pipeline code is verified for syntax errors as shown in above screenshot](/files/-MgIL0ETpCKFDegG5jEi)

Step &#x34;**:** Click execute button to execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Screenshot-1](/files/-MgILczH8wN_eztiZIf2)

RDA executes a loop-count-based pipeline and prints the loop details as shown in the above screenshot. During each iteration/loop, the pipeline screen updates the iteration number as shown in the above screenshot.

![](/files/-MgIM71eqLV_hqEIo3BQ)

After iterating till 'end', pipeline data is stored in output and exits.

![Output is printed after end of all iterations as shown in the above screenshot.](/files/-MgIMhC-RojPqucAPX3-)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/loop-operations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
