Data360 Analyze

 View Only
  • 1.  Concatenate 2 columns into one

    Posted 12-08-2022 11:41

    Hi, I have seemingly simple question that I'm stuck on. 

    How to concat in transform node 2 columns into one, new column? Like name and surname into new fullName column? python's for i in zip throws error. 

    Thanks!



    ------------------------------
    Irakli Chitishvili
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Concatenate 2 columns into one

    Employee
    Posted 12-09-2022 09:56
    I need a lot more details to be able to answer.  What is the error message?  What is the context?

    When you say, "python's for i in zip throws error" I can't help wondering if you are missing the colon (:) character at the end of that line.

    My first thought is that this code, in1.color + " " + in1.type, concatenates two columns with a space between them.  Just to be sure, I tested it and the error thrown had to do with Null in those fields in some of the records of the default "Create Data" node.  So I added code to handle Nulls:
    if in1.color is Null:
        if in1.type is Null:
            x = Null
        else:
            x = in1.type
    else:
        if in1.type is Null:
            x = in1.color
        else:
            x = in1.color + " " + in1.type
    
    out1.x = x
    ​


    ------------------------------
    Ernest Jones
    Precisely Software Inc.
    PEARL RIVER NY
    ------------------------------



  • 3.  RE: Concatenate 2 columns into one

    Posted 12-12-2022 02:25
    Thank you for your response. What I was trying is to join two columns in the table which has total 12 columns and add additional 13th based on the the concatenation. I will try your solution and see how it goes.

    Thanks again!

    ------------------------------
    Irakli Chitishvili
    Knowledge Community Shared Account
    ------------------------------



  • 4.  RE: Concatenate 2 columns into one

    Posted 12-20-2022 03:25

    configurefields:

    out1+= in1

    out1.FullName = str


    Processrecords:


    if in1.name and in1.surname: #if name and surname column != null

    out1.FullName = in1.surname + " " + in1.name #then give output







    this works when in1.name and in1.surname isn't null

    ------------------------------
    Henrik B
    Knowledge Community Shared Account
    ------------------------------