Skip to Content
avatar image
Former Member

Separator UDF

Hi,

In the mapping Source field has the value XXX_YY_ZZ. I need XXX in target field1, YY in target field2 & ZZ in target field3.

Kindly suggest if any standard function s available or how to go about this.

eg

source abcd_abc_asdff

target field1 - abcd

target filed2 - abc

target field3 - asdff

Thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 18, 2010 at 08:10 AM

    Hi ,

    You can create 3 UDF as shown below:

    public String getStr1(String input, Container container)
    {
    String arr[] = input.split("_");
    return arr[0];  // for other 2 string use arr[1] and arr[2]
    }

    or create ony one UDF with index also as a input.

    Regards,

    Sunil Chandra

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Adding to sunil's comment..

      you can include one more parameter for index.. to avoid separate UDF for each fields.

      public String getStr1(String input, Container container)

      Parameters: input, indexVal

      
      String arr[] = input.split("_");
      return arr[indexVal];  // for other 2 string use arr[1] and arr[2]
      
      

      Mapping

      Source + Constant (0 or 1 0r 2) -- > UDF -- > Target

      Regards

      Ramg

  • Jun 18, 2010 at 08:57 AM

    If your source format standard then use substring function,if the length is going to vary then use sunil UDF.

    Add comment
    10|10000 characters needed characters exceeded