开发者

swapping selected values from one column to other using any transformation

I have two columns named amount and work with data in the format of given below:

amount   58220  84151 65999    23    78544   开发者_Go百科 52656       
work        15     14    20    85597    22       19

and I want to swap the values of 23 and 85597 which are in the same row. Can you suggest me a suitable solution?


Create a transformation following the steps:

  1. build file inputdata.txt (or other source of data for the flow)

    value1, value2
    58220,  15
    84151,  14
    65999,  20
    23,     85597
    78544,  22
    52656,  19
    
  2. add code in javascript step

    var t1 = value1;
    var t2 = value2;
    
  3. In the menu "Fields" choose Rename t1 to value2 and t2 to value1 and check the option to replace values??.

  4. the results are:

    value1, value2
    15,     58220          
    14,     84151          
    20,     65999          
    85597,  23             
    22,     78544          
    19,     52656 
    

If you need the source code I send by email.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜