Skip to main content

Hello Users,


Attached the Workspace with the transformer PythonCaller. This transformer receive the attributes from Souce Data ( list values ) and generate two new Attributes to each list value : initial and final. This is Works fine.

 





So now i need to create 4 news attributes to each list values: Initial_even, End_even, Initial_odd and End_odd.

For example to list 1:

Inicial: 0
Final: 40


How it be:

Initial_even:0
End_even: ( Initial_even.list1{} + attribute lenght this list ( int(listaTamanhoTrechoocontrole] )) = 40

Initial_odd: ( Initial_even.list1{} + 1 ) = 1
End_odd: ( End_even.list1{} + 1 ) = 41

 




To list 2

Initial_even: ( End_even.list1{} + 2 ) = 42
End_even: ( Initial_even.list2{} + attribute lenght this list ( int(listaTamanhoTrechohcontrole] )) = 126

Initial_odd: ( Initial_even.list2{} + 1 ) = 43
End_even: ( End_even.list2{} + 1 ) = 127

 





To list 3


Initial_even: ( End_even.list2{} + 2 ) = 128
End_even: ( Initial_even.list3{} + attribute lenght this list ( int(listaTamanhoTrechoccontrole] )) = 255 *** How this value is odd, is necessary to transform to even value: +1 = 256

Initial_odd: ( Initial_even.list3{} + 1 ) = 129
End_odd: ( End_even.list3{} + 1) = 257

 

Thanks

Hi @danilo_inovacao, sorry I'm completely unclear the requirement. What are the 'list 1', 'initial_even.list1{}', 'End_even.list1{}', etc. in your description? Does the 'attribute length' mean the number of characters of the attribute value?

If you are just looking for a way to determine if an integer is even or odd, divide the number by 2 and then see if the reminder is 0 or 1. The % operator is helpful.


Hi @danilo_inovacao, sorry I'm completely unclear the requirement. What are the 'list 1', 'initial_even.list1{}', 'End_even.list1{}', etc. in your description? Does the 'attribute length' mean the number of characters of the attribute value?

If you are just looking for a way to determine if an integer is even or odd, divide the number by 2 and then see if the reminder is 0 or 1. The % operator is helpful.

There's even a ParityFilter on the FME Store that will test for odd/even values of integers.

 

 


Reply