Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 05:30 AM
To access the individual items from your list [1, 2, 3, 4] in the notebook for each iteration of the For Each task, you can use the {{input}} reference. Here’s a step-by-step example to help you understand how to achieve this:
-
Define the For Each Task:
- Create a new For Each task in your job configuration.
- Set the
inputsfield to your list:"[1, 2, 3, 4]". - Configure the nested task that will run for each item in the list.
-
Configure the Nested Task:
- In the nested task, use the
{{input}}reference to access the current item in the iteration. - For example, if you are using a notebook task, you can pass the
{{input}}as a parameter to the notebook.
- In the nested task, use the
-
Access the Parameter in the Notebook:
- In your notebook, use
dbutils.widgets.getto retrieve the parameter value.
- In your notebook, use
Here’s an example configuration:
{
"name": "Process Items",
"tasks": [
{
"task_key": "process_items",
"for_each_task": {
"inputs": "[1, 2, 3, 4]",
"task": {
"task_key": "process_item_iteration",
"notebook_task": {
"notebook_path": "/path/to/your/notebook",
"base_parameters": {
"item": "{{input}}"
}
}
}
}
}
]
}