on 06-25-2008 11:52 AM
Hello Friends,
I want to concatenate all value of the same context separated by comma and wants a result as an string.
Example.
values in the same context are like this
1
2
3
4
5
The Result should be like this
1,2,3,4,5
Please suggest the correct UDF code for this.
Regards,
Sarvesh
function myudf(String a[[]], ResultList result,Container container)
{
String target="";
for(int i=0;i<a.length-1;i++)
target=targeta[<i>]"," ;
target=target+a[<i>];
result.addValue(target);
}
/people/harrison.holland5/blog/2006/12/08/mapping-context-changes-in-xi
/people/jeyakumar.muthu2/blog/2005/12/19/data-mining-using-apriori-algorithm-in-xi-150-part-ii
Edited by: Gabriel Sagaya Selvam on Jun 25, 2008 5:09 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gabriel,
you code helpd me lot.
The exact code should be like this.
> function myudf(String a[[]], ResultList result,Container container)
> {
> String target="";
> for(int i = 0;i<a.length;i++)
> target = targeta[<i>]"," ;
> }
> result.addValue(target);
>
Now only the thing I am getting comma at the end of my string, so m working on that.
If you have some suggestion for that you are most welcome.
Regards,
Sarvesh
Any one... plz give me your valuable suggstions..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarvesh,
U can do it with UDF.
Write for loop and inside for loop use the java concat function.
refer the below example
1) "cares".concat("s") returns "caress"
2) "to".concat("get").concat("her") returns "together"
where S replace by a[i[ variable inside the for loop. u also need one variable which stores the previous concat value.
chirag
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.