Data360 Analyze

 View Only
  • 1.  Transform Node

    Posted 05-08-2022 02:49

    I have a set of data with more 2K+ and it contains mix of letter and numbers as it show on the sample. I need to emit the number from it and still kept the original by using the Transform node or any possible way. For example, ad71296 --> the NewField should contain = 71296...

    ad71296
    sulieti2018
    ad37010
    ad21301
    ad22068
    pad21860

     



  • 2.  RE: Transform Node

    Posted 05-09-2022 01:37

    It really depends on how complex it needs to be but Python actually supports filtering inline for DIGITS

    configure

    out1.ints = str

     

    Process

    out1 += in1

    str1 = fields.data
    out1.ints = int(filter(str.isdigit, str1))

     

    INPUT

    re456ty
    45jk5k5l
    34e34e
    eerrtt44

     

    OUTPUT

    456
    4555
    3434
    44



  • 3.  RE: Transform Node

    Employee
    Posted 05-09-2022 01:59

    As John's reply shows - there are several ways this can be done. Here is an example using regular expressions.

    ## ConfigureFields Script

    import re

    #Configure all fields from input 'in1' to be mapped 
    #to the corresponding fields on the output 'out1'
    out1 += in1

    out1.DigitsOnly = unicode

    pattern = r'^([a-zA-Z]+)(\d+)$'

    ## ProcessRecords Script

    #Copy all fields from input 'in1' to the corresponding output fields
    #in output 'out1'. Copies the values of the fields that have been setup
    #in the mapping defined in the ConfigureFields property
    out1 += in1

    if fields.Data == Null or fields.Data == "":
      out1.DigitsOnly = Null
    else:
        match = re.match(pattern, fields.Data)
        if match:
            out1.DigitsOnly = match.group(2)
        else:
            out1.DigitsOnly = Null

     

     

     

     



  • 4.  RE: Transform Node

    Posted 05-10-2022 10:00

    thank you...appreciate the help