Transform arrays by removing elements, renaming keys or sorting the elements.
The transformations are done in the aforementioned order by defining Python code snippets. The snippets can contain following variables:
Variable | Explanation |
---|---|
key | the string containing the key to the original array element |
index | the row number in the original array file, starting from 0 |
new_index | the row number in the output array, again starting from 0 |
filename | the name of the file the element in the array points to |
path | path to the file that the element in the array points to |
Version | 1.0 |
---|---|
Bundle | builtin |
Categories | |
Specialties | generic |
Authors | Mikko Kivelä (bolozna@gmail.com) |
Issue tracker | View/Report issues |
Requires | Python |
Source files | component.xml arrayTransformer.py |
Usage | Example with default values |
Name | Type | Mandatory | Description |
---|---|---|---|
in | Array<T> (generic) | Mandatory | The original array |
aux | BinaryFile | Optional | Auxiliary data |
Name | Type | Description |
---|---|---|
out | Array<T> (generic) | The transformed array |
Name | Type | Default | Description |
---|---|---|---|
order | string | "index" | A Python script snippet giving a value which is used to order the elements in the array. The default value keeps the original order. Small values come first in the array. |
preprocess | string | "" | A Python script which is executed before the tranformation process begins. All the variables defined in this script can be used later in remove, rename and order parameters. |
remove | string | "False" | A Python script snippet to decide if the element in the array should be removed. The value of the snippet should take value True if the element is removed and False otherwise. With the default value nothing is removed. Note that the new_index variable has the value for the index that the element would have if it is not removed |
rename | string | "key" | A Python script snippet giving a key, or name, for the array element. The default value keeps the old key. |
Test case | Parameters▼ | IN in |
IN aux |
OUT out |
||
---|---|---|---|---|---|---|
case1_renaming | properties | in | (missing) | out | ||
rename=key+"_"+str(index) |
||||||
case2_sorting | properties | in | (missing) | out | ||
order=int(key[3:]) |
||||||
case3_removing | properties | in | (missing) | out | ||
remove=index%2!=0 |