We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.
Our Support systems migrated on Saturday, May 21. We'll automatically forward you to the new location for this content.

Look for zip code less than 5 digits

Comments

3 comments

  • Avatar
    John Taylor

    Hi Mike,

    The transform node could gives you any number of ways to do this with some fairly simple Python.

    For an even easier solution we can use the Filter node's "Advanced" feature to add the python function of LEN() to count the length of the test and filter record in or out.

    simply swap the field name on your input pin for the 'ZipCode' field I created in the example above.

    This example filter find all the records with less than (<) a length of 5 characters. You can swap the '<' character for;

    • '!=' to show all records that DO NOT have a length of 5 (that way to could get the ones over 5 at the same time)  
    • "==" to just return the records WITH a length of 5. Good if you wanted to removed the bad records and continue
    • ">" to show only the records with a length OVER 5 characters

     

    One could take this one step further and use a "split" node, which uses the same underlying code as the filter node, but not only do you get the matches for your filter criteria, you get the records that don't match on a 2nd output pin.

    In the example above you can see we get the 4 records that are under a length of 5 on the 1st pin and the 11 records that are the perfect length of 5 on the 2nd pin, really cool to progress your flow and still exception manage those 'bad' records with an email alert or writing them off to a file.

    Have a play and let us know how you get on :)

    Good luck!

    John

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    You can also use regular expressions in a Transform node to identify strings with a zip or zip+4 formats:

    ConfigureFields Script

    ProcessRecords Script

    Example results:

    See the attached example data flow

     

    Attached files

    Check_Zip_Code_Validity - 20 May 2022.lna

     

    0
    Comment actions Permalink
  • Avatar
    Mike Spalding

    Adrian, John, 

    Thanks to both of you for responding.  Both solutions worked great!  John, I did have to account for NULL in my data but I just put a split node in front of your filter solution and it worked fine.  Thanks again.

    0
    Comment actions Permalink

Please sign in to leave a comment.