InvertEveryTwoItems
This transformer will invert every two items in an array. Example: ["A", "B", "C", "D"] Result: ["B", "A", "D", "C"] If the total of items in the array is an odd number the last item will be removed Example: ["A", "B", "C", "D", "E"] Result: ["B", "A", "D", "C"] If the item is not an array the output will be same passed object.
python · Community Common Scripts
Details
| ID | InvertEveryTwoItems |
|---|---|
| Language | python |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.13.11879924 |
| Tags | transformer list |
README
This transformer will invert every two items in an array.
Example:
[“A”, “B”, “C”, “D”]
Result:
[“B”, “A”, “D”, “C”]
If the total of items in the array is an odd number the last item will be removed
Example:
[“A”, “B”, “C”, “D”, “E”]
Result:
[“B”, “A”, “D”, “C”]
If the item is not an array the output will be same passed object.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer, list |
Inputs
| Argument Name | Description |
|---|---|
| value |
Outputs
There are no outputs for this script.
args: - isArray: true name: value description: Input list. comment: "This transformer will invert every two items in an array.\nExample: \n[\"A\", \"B\", \"C\", \"D\"]\nResult:\n[\"B\", \"A\", \"D\", \"C\"]\n\nIf the total of items in the array is an odd number the last item will be removed\nExample:\n[\"A\", \"B\", \"C\", \"D\", \"E\"]\nResult:\n[\"B\", \"A\", \"D\", \"C\"]\n\nIf the item is not an array the output will be same passed object." commonfields: id: InvertEveryTwoItems version: -1 contentitemexportablefields: contentitemfields: fromServerVersion: '' dockerimage: demisto/python3:3.12.13.11879924 enabled: true name: InvertEveryTwoItems runas: DBotWeakRole script: '' scripttarget: 0 subtype: python3 tags: - transformer - list type: python fromversion: 6.0.0 tests: - No tests (auto formatted)