MapRangeValues
This script converts an input value into another value using two lists. The input value or range is searched in the first list (map_from). If it exists, the value at the same index from the second list (map_to) is returned. If there is no match, the original value is returned. This script supports mapping from either ranges of float numbers or text strings. Example 1: map_from = "1,2,3,4" map_to = "4,3,2,1" value = 3 Output is "2" Example 2: map_from = "1-3,4" map_to = "5,1" value = 3 Output is "5".
python · Filters And Transformers
Details
| ID | MapRangeValues |
|---|---|
| Language | python |
| From Version | 6.1.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | transformer |
README
This script converts an input value into another value using two lists. The input value or range is searched in the first list (map_from).
If it exists, the value at the same index from the second list (map_to) is returned. If there is no match, the original value is returned.
This script supports mapping from either ranges of float numbers or text strings.
Example 1:
map_from = “1,2,3,4”
map_to = “4,3,2,1”
value = 3
Output is “2”
Example 2:
map_from = “1-3,4”
map_to = “5,1”
value = 3
Output is “5”
map_from = “0,0.5,1,2,3,4”
map_to = “Unknown,Informational,Low,Medium,High,Critical”
value = 3
Output is “High”
map_from = “Unknown,Informational,Low,Medium,High,Critical”
map_to = “0,0.5,1,2,3,4”
value = Informational
Output is “0.5”
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer |
| Cortex XSOAR Version | 6.1.0 |
Inputs
| Argument Name | Description |
|---|---|
| map_from | A comma-separated list of values to map from. |
| map_to | A comma-separated list of values to map to. |
| sep | The separator between the start and end of range values. |
| value | the input value to map. |
Outputs
There are no outputs for this script.
commonfields: id: MapRangeValues version: -1 name: MapRangeValues script: '' type: python tags: - transformer comment: |- This script converts an input value into another value using two lists. The input value or range is searched in the first list (map_from). If it exists, the value at the same index from the second list (map_to) is returned. If there is no match, the original value is returned. This script supports mapping from either ranges of float numbers or text strings. Example 1: map_from = "1,2,3,4" map_to = "4,3,2,1" value = 3 Output is "2" Example 2: map_from = "1-3,4" map_to = "5,1" value = 3 Output is "5". enabled: true args: - name: map_from required: true isArray: true description: A comma-separated list of values to map from. - name: map_to required: true isArray: true description: A comma-separated list of values to map to. - name: sep required: false default: true defaultValue: '-' description: The separator between the start and end of range values. - name: value required: true description: the input value to map. isArray: true scripttarget: 0 isllm: false subtype: python3 dockerimage: demisto/python3:3.12.13.10404775 runas: DBotWeakRole fromversion: 6.1.0 tests: - MapRangeValuesTest