BatchData
This Automation takes in a string of comma separated items and returns a dictionary of with the defined chunk size.
python · Community Common Scripts
Source
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 batch_size = demisto.args()["batch_size"] list_of_items = demisto.args()["data"] context_path = demisto.args()["context_path"] list_of_items = list(list_of_items.split(",")) batch_size = int(batch_size) batch_list = [] for i in range(0, len(list_of_items), batch_size): batch_list.append(list_of_items[i : i + batch_size]) context = {"BatchedData": {context_path: batch_list}} demisto.results({"Type": entryTypes["note"], "Contents": context, "ContentsFormat": formats["json"], "EntryContext": context})
README
This Automation takes in a string of comma separated items and returns a dictionary of with the defined chunk size.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags |
Inputs
| Argument Name | Description |
|---|---|
| batch_size | number of items that will be returned in each dictionary items (must be of type int) |
| data | comma separated list of items |
| context_path | This nest the path under BatchedData in context. If you are running this script multiple times/simultaneously in a playbook, your data will be over written. |
Outputs
There are no outputs for this script.