9.2.1.4. Example 4

<< Click to Display Table of Contents >>

Navigation:  9. Anatella for the Expert Users > 9.2. About the integration of Javascript, R, Python inside Anatella > 9.2.1. JavaScript Integration inside Anatella >

9.2.1.4. Example 4

 

Let’s now change one last time our Anatella-Script to obtain (Please note that we removed one of the two “Key” columns):

 

+-----------------+         +-------------------------------------------+

|  INPUT TABLE    |         |               OUTPUT TABLE                |

+---+------+------+         +---+---------+---------+---------+---------+

|Key|Field1|field2|         |Key|T1.Field1|T1.field2|T2.Field1|T2.field2|

+---+------+------+         +---+---------+---------+---------+---------+

|  0|     A|     B|         |  0|        A|        B|       AA|       BB|

|  1|    AA|    BB|         |  2|      AAA|      BBB|     AAAA|     BBBB|

|  2|   AAA|   BBB|         +---+---------+---------+---------+---------+

|  3|  AAAA|  BBBB|

+---+------+------+

 

 
The Anatella-script of this new transformation is (we have added into the code the lines marked with vertical red lines: These are the lines 7,34,37):
 

AN76E5~1_img112

 

 
The objectives of the code modifications are:
 

1.to avoid the duplication of the ‘Key’ column in the output table: see line 7.

2.to avoid renaming (to “T1.Key”) the ‘Key’ column: see lines 34 and 37.

 

Inside this last script, we used the Anatella-specific-global-function  “dropColumn(outputPinIndex,columnIndex)” that removes one column on one of the output pins.
 
Anatella offers you several global functions that allow you to select exactly which column will be included in the output table. These global functions are:
dropAllColumns(outputPinIndex)”, “keepAllColumns(outputPinIndex)”, “dropColumn(outputPinIndex,columnIndex)”,  “keepColumn(outputPinIndex,columnIndex)”.

 

You can use also the global function “keepColumn(outputPinIndex,columnIndex)” to re-order the columns of the output table. For example, the script:
 

 dropAllColumns(0);

 keepColumn(0,2);

keepColumn(0,1);

keepColumn(0,0);

 
… creates a 3-columns-output-table and the column-order is reversed (2,1,0 instead of 0,1,2) compared to the original order in which you have written the data.

 

The source codes of the default Anatella-Script Actions provided with the Anatella software are good examples and good sources of inspiration. I invite you to read them.