on 10-19-2008 9:24 AM
Hi Experts,
I am reading entire file content in single feild in source data type.I want to write a UDF to seach for a particular pattern(say :25: and store the value after it i.e 34535764778 detination for further use).
EX: My sample file and its has feilds like
}
point assured
Thanks
HI Sri,
You are sending entire data to a single field as array. right?
If yes then create a advanced udf
//write your code here
String s="";
for(int i=0;i<a.length;i++){
int start = a.indexOf(u201C:25:u201D);
int end = a.indexOf(u201C:28Cu201D);
s = a.substring(start+4,end);
}
+result.addValue(s);+
The above udf gives the output as 34535764778
If any changes required let me know.
Regards
Sridhar Goli
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi i tried the UDF given by you, it shows errors when i run the mapping test
47: illegal character: 8220 int start = a.indexOf(âu20ACu0153:25:âu20AC?); ^
47: ')' expected int start = a.indexOf(âu20ACu0153:25:âu20AC?); ^
i have taken input as the data which i have givenin my thread.
Please let me know if you can figure out the reason for this error.
The code worked fine thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi since u are using a single field only then u dont need to use any advanced function
Wel because if u see the formation of the queue u wil find the the whole data is under one context.. and there are not more context changes
Convert the string to an array and progressively u can check for the four checks if the a<i>=:
then a[i+]=2 then a[i]=5 and a[i+] =: and then substring the next 7-8 chrac.. hope u understand
If this also doesnt work wel then u will have to use the Pattern class in Java
By the way remember that the substring value cant be retained for the next instance of mapping
Hope u have that in mind...
Rgds
Aditya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the logic should be as follows;
create an advanced UDF.
1. Loop for the length of the array (queue) of the input.
2. search for the index of :25:
3. if index is >= 0, then extract the substring of the last index of : to the length of the current string
thats it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.