Data360 Analyze

 View Only
  • 1.  Check field type and Convert to int dynamically in a transform node?

    Posted 12 days ago

    I am trying to read all the fields in and convert them to integer....

    i know this isnt right.. but something like this

    so no matter how many fields you feed in, it will convert them all to integers type

    i=0
    while i < len(inputs[0]):
        outputs[0][inputs[0][i].name] =str
        i=i+1
    I would also like to know how to check the field type for data transformation...
    like:
    If inputs[0][i] is Date:
        do this....
    elif inputs[0][i] is string:
    etc...


    ------------------------------
    Geoff Geoff
    Windstream Communications
    Little Rock AR
    ------------------------------


  • 2.  RE: Check field type and Convert to int dynamically in a transform node?

    Posted 11 days ago

    Something I have some stuff which converts to unicode.

    Process records:

    for fieldName in in1:
        out1[fieldName] = unicode


    Configurefields:

    for fieldName in in1:
        if in1[fieldName] is not Null:
            out1[fieldName] = unicode(in1[fieldName], "utf-8")


    You can do something similar for integers.

    --

    Suggestion for field type checking and conditional execution - do something like this:

     if isinstance(x['type'],unicode):
         ...
     elif isinstance(x['type'],dict):                

       ...

     if isinstance(x['type'], list):

       ..

    etc



    ------------------------------
    Peter Sykes
    Data Governance & Architecture
    Vontobel Holding AG
    Zurich
    ------------------------------



  • 3.  RE: Check field type and Convert to int dynamically in a transform node?

    Posted 11 days ago

    EXACTLY WHAT I WAS LOOKING FOR!

    Thank you!!



    ------------------------------
    Geoff Geoff
    Windstream Communications
    Little Rock AR
    ------------------------------