Thursday, October 22, 2015

Datastage -Functions in Transformer


1.  AlNum(%string%)
Allnum(“12345”) --- output-1
Allnum(“abcd”) --- output-1
Allnum(“ab125”) --- output-1
Allnum(“@a12345”) --- output-0
Allnum(“@a1 2345”) --- output-0
Except Special Symbols (Letters & Numbers) it will give output as “1”
2. Alpha(%string%)
Alpha (“abcd”) --- output-1
Alpha (“12345”) --- output-0
Alpha (“ab125”) --- output-0
Alpha (“@a12345”) --- output-0
Alpha (“@a1 2345”) --- output-0
3. Compactwhitespace(%string%)
     It reduces or replaces multiple spaces into single space.
Ex: CompactWhiteSpace("sud hee                  r") 
            Out Put: sud hee r
4. Space(length):

     Inserts no.of white spaces given in lengthy parameters.
        Ex:-Space(6):’Brahma’
       Output: Brahma

5 . Len(string):
Returns length of string in characters
     Ex:- Len(space(6):’Brahma’)
     Output---12
     Ex:- Len(“Brahma”)
      Output—6
6. Compare(String1,String2,[Justification]):       //case sensitive
      Compares String1 & String2,if String1 is greater than String2 it will result 1
            If String1 is less than String2,then it will result 1.
            If both the strings are equal then it will result 0.
            To compare String1 with String2, we give Justification:L
           To compare String2 with String1,we give Justification:R
     Ex:       Compare(“abcd”,”abc”,”L”)---output-1
                  Compare(“abcd”,”abc”,”R”)---output-0
                  Compare(“abc”,”Abc”)---output-1     Default Justification-L
                  Compare(“abc”,”abcd”)---output  -1
7. CompareNoCase(String1,String2):
             Same as Compare,but diff is this function is NOT case sensitive.
          In this function no argument called Justification.
8. CompareNum(String1,String2,length):
           Compares two strings up to the given length.
           Ex:-     CompareNum(“a”,”abc”,1)     output---0
                       CompareNum(“a”,”abcde”,5) output--    -1
           CompareNum(“abcde”,”a”,5) output---1
           CompareNum(“abcde”,”Abcde”,1)    output---1
           CompareNum(“Abcde”,”abcde”,1)    output--   -1
9. CompareNumNoCase(String1,String2,length):
          Same as CompareNum, diff is this function is NOT case sensitive.
          Ex:-     CompareNumNoCase(“Abcde”,”abcde”,5)   output---0
         CompareNumNoCase(“abxye”,”abcde”,5)    output---1
         CompareNumNoCase(“abcde”,”abxde”,5)    output--  -1
10. Upcase(String):
           Change all lowercase letters in a string to uppercase.
           Ex:-     Upcase(“brahma”)       output—BRAHMA
           Upcase(“braHma”)      output----BRAHMA
11. DQuote(String):
          Enclose a string in double quotation marks.
         Ex:-     DQuote(Upcase(“brahma”))   output---“BRAHMA”
        DQuote(‘brahma’)                  output---“brahma”
12. Field(String,delimiter,occurrence,number):
          Returns the substring before delimiter based on occurrence we are given.
            Ex:-     Field(“br_ah_ma_na”,”_”,2)   output---ah
         Here ah is substring before the second occurrence of delimiter ‘_’.
Field(“br_ah_ma_na”,”_”,3)   output---ma
         Here after ma _ is third occurrence.
Field(“br_ah_ma_na”,”_”,1,4)            output---br_ah_ma_na
Field(“br_ah_ma_na”,”_”,1,2)            output---br_ah
Field(“br_ah_ma_na”,”_”,1,3)            output---br_ah_ma
Field(“br_ah_ma_na_a”,”_”,1,5)        output---br_ah_ma_na_a
 Note:-
          Field(“brahmananda”,”a”,2)   output—hm
   Here ‘a’ is delimiter
         Field(“brbhmananda”,”a”,2)   output—n
         Field(“brhhmananda”,”a”,1)   output—brhhm
          Field(“brahmananda”,”a”,1,3)  output—brahman

13. Index(String,substring,occurrence):
        Returns starting character position of substring.
        Ex:-     Index(“brahma”,”a”,1)            output---3
        Index(“brahma”,”a”,2)            output---6
        Index(“brahmananda”,”a”,3)  output---8
        Index(“brahmananda”,”na”,1)  output---7
14. Convert(fromlist,tolist,Expression)
      Converts specified character in a string(given in expression arg) to designated replacement character
      Ex:-  convert(“a”,”y”,”brahma”)
   o/p:byhmy
             convert(“ah”,”y”,”brahma”)
   o/p:brymy
      This function performs character replacement, but not word.
      Ex:  convert(“brahma”,”msrmad”,”brahma”)
15. Count(String,Substring):
      Count number of times a Substring occurs in a String.
      Ex:Count(“brahma”,”a”)
            o/p:2
           Count(“brahmabaabaaba”,”ab”)
            o/p:3
          Count(“brahmabaabaaba”,”ba”)
            o/p:3
16. DCount(String,Delimiter):
      Count number of delimited fields in a string.
     Ex:  DCount(“br-ah-ma-na”,”_”)-------o/p:4
             DCount(“br,ah,ma,na”,”,”)-------o/p:5
             DCount(“br,ah-ma,na”,”,”)-------o/p:4
    ah-ma, treats as one field
17. Downcase(String):
       Change all uppercase letters in a String to lowercase
     Ex:  Downcase(“BRAHMA”)------o/p:brahma
             Downcase(“brHMA”)------o/p:brahma
             Downcase(“BRAhma”)------o/p:brahma
18. Left(String,length)
        Returns leftmost ‘n’ characters of the string, where n is length.
      
       Ex:  Left(“brahmananda”,4) o/p:brah
               Left(“bra__hmananda”,6) o/p:bra_hm
19. Right(String,Length)
      Returns rightmost ‘n’ characters of the string
    
      Ex:   Right(“brahmananda”,4) o/p:anda
20. Num(String)
     Returns 1 if string can be converted to a number.
     
     Ex:    Num(“brah”)    o/p=0
              Num(“369”)     o/p=1
21. PadString(String,PadString,Padlength)
       Returns the string padded with the optional pad character and padlength is the number of times it add to the original string
    
      Ex:    PadString(“brahma”,”+”,5)    o/p:brahma+++++
                PadString(“brahma”,”reddy”,5)   o/p:brahmarrrrr
22. Str(String,repeats)
       Repeats the input string no.of times given in repeats
    
      Ex:  Str(“mbnr”,2)    o/pmbnrmbnr
23. StripWhiteSpace(String)
       Returns the string after stripping (removing) all white space from it.
     
     Ex:  StripWhiteSpace(“br a h ma”)   o/p:brahma

No comments:

Post a Comment

Talend Cloud Data Connectors

  List of supported  Talend Cloud Data Connectors List of the environments and systems to which you can connect. Unless stated otherwise...