Concatenation with NULL fields

Comments

6 comments

  • Avatar
    Adrian Williams

    Yes, you cannot concatenate a Null object with a string. You can test the input fields to check if one or both fields are not Null and use assign the appropriate value or the concatenation to the output field, or a default value for the case where both are Null.

    Alternatively, you can use the Calculate Fields node and create a simple expression to concatenate the fields e.g.

    Column_A + Column_B

    The node's DefaultValueForNullText property specifies the default value that will be used in expressions when a field's data is string/unicode and the value is Null. If the property is not set an empty string is used as the default value. 

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    The Transform use case would use a ProcessRecords script similar to this:

     

    0
    Comment actions Permalink
  • Avatar
    Stéphane O

    Thanks a lot Adrian, but I have to concatenate 6 fields. Writing a script with all possible cases is unreal.

    Will definitively use the 'Calculate Field' node which is working properly.

    How the same action could be OK with a node and not OK with an other one?!?

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    The Transform node is operating correctly. In Python the action of concatenating a string value with a Null (None) object is not defined and will generate an error.

    The Transform node enables users to leverage the flexibility and power of the Python language with minimal abstraction.

    The Calculate Fields node was designed to provide a mechanism for users to employ simple expressions to generate new fields and one aspect of this was to streamline the processing of Null values through the introduction of properties to define a value to be used for certain field types when a Null value was encountered when evaluating an expression.

    The Transform node can be used to concatenate multiple fields, the attached .lna file shows an example of how you can use iterators in Python to cycle through a list of fields to be concatenated. Analyze 3.4.0 or above is required to import the data flow.

     

     

    Attached files

    Concatenate_Multiple_String_Fields - 16 Jul 2019.lna

     

    0
    Comment actions Permalink
  • Avatar
    Stéphane O

    Thanks a lot Adrian for your swift answer. It works perfectly :)

    0
    Comment actions Permalink

Please sign in to leave a comment.



Powered by Zendesk