9.2.1.2. Example 2

<< 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.2. Example 2

 

Using the knowledge acquired in the previous section, we can already design a new Anatella-script that performs the following transformation:

 

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

    |  INPUT TABLE    |             |            OUTPUT TABLE           |

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

    |Key|Field1|field2|             |Key|Field1|field2|Key|Field1|field2|

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

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

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

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

    |  3|  AAAA|  BBBB|

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

 
 

The Anatella-script of this new transformation is:

 

AN76E5~1_img110

 

 
The principle of the above script is simple:
 

1.On line 10 and 14, we read two consecutive rows of the input table (these rows are stored in ‘r1’ and ‘r2’)

 

2.On line 17 and 18, we write on the same output row on pin 0 the two rows (‘r1’ and ‘r2’) that we just read. These 2 input rows will thus both end-up on the same output row. On line 19, we write the “End-Of-Line” marker on the output pin 0, to mark the end of the output row.

 

We won’t explain inside this section the meaning of the line 12: please refer to the later section 9.2.1.5. to have more information about this subject.