Zapier extract address from text

39 views Asked by At

I have a zap which gets address information but is nested in a message format with other contact details. I would like to extract the address from the text only. The text is provided in the following format;

Name: Ellie Bloggs

Company: Test Company

Call back number: 020 87206495

Email: [email protected]

Address: 6 Test Street, London, E1 2LA

Call regarding: She would like a drone roof survey at one of their properties as they would like to highlight repairs needed. She said that it is a four or five storey property with very limited roof access*

The text is always formatted in a block with the different contact details on a new line. Does anyone know how this can be achieved?

1

There are 1 answers

0
Usman Ashraf On

You can add a simple Python script in Zapier to handle this. Something like the following can help you get there:

Let's assume input_string contains all the info that you mentioned above in a string format. Then, you can run the following to extract the address out of it:

def process_text():
    address = None
    info_strings = input_string.split('\n') # to split the string into different pieces
    for item in info_strings: # iterate over string pieces
        if "Address:" in item: # find the string piece with Address in it
            item.split("Address:")[-1].strip() # strip out the address 
    return address

This will return the address variable i.e. the address extracted from the string shared.

Let me know if there are any questions.