KAPOW

Would you like to react to this message? Create an account in a few clicks or log in to continue.
KAPOW

Welcome to the Kapow forum. Here you can get help, use your skills to help others and enjoy hanging out in the company of other Kapow Robot Developers.


3 posters

    Help with divide lines

    avatar
    News24


    Posts : 12
    Points : 3833
    Join date : 2014-06-02

    Help with divide lines Empty Help with divide lines

    Post by News24 Thu Sep 18, 2014 3:16 pm

    Hi,
    Have next lines:
    Code:
    Edmonton Alberta T5K 2T8
    Calgary Alberta T2Y 3W5
    Red Deer Alberta T4R 2T4
    Grande Prairie Alberta T8V 7X5
    North Vancouver British Columbia V7M 2J3
    Maple Ridge British Columbia V2X 2P9

    I can divide zip codes (using regexp). But how I can split the State name and City name?
    jking
    jking


    Posts : 103
    Points : 4051
    Join date : 2014-03-01
    Location : USA

    Help with divide lines Empty Re: Help with divide lines

    Post by jking Tue Sep 23, 2014 1:26 am

    You will need to insert a Convert Variable step with a Replace Pattern Converter.  You will need to pattern out each variable part you need (City, State, Postal Code).  The tricky part is that it appears the Provence's are spelled out, not abbreviated...   you may need to do insert a test variable step with one branch for each Provence.  That would actually make your Replace Pattern much easier as well.  Good Luck.
    avatar
    News24


    Posts : 12
    Points : 3833
    Join date : 2014-06-02

    Help with divide lines Empty Re: Help with divide lines

    Post by News24 Tue Sep 23, 2014 6:15 pm

    jking wrote:You will need to insert a Convert Variable step with a Replace Pattern Converter.  You will need to pattern out each variable part you need (City, State, Postal Code).  The tricky part is that it appears the Provence's are spelled out, not abbreviated...   you may need to do insert a test variable step with one branch for each Provence.  That would actually make your Replace Pattern much easier as well.  Good Luck.
    Can you show example? I Can't understand what you mean.
    jking
    jking


    Posts : 103
    Points : 4051
    Join date : 2014-03-01
    Location : USA

    Help with divide lines Empty Re: Help with divide lines

    Post by jking Thu Sep 25, 2014 3:51 am

    This response assumes that you extracted the location into a variable (I will use nextline for my variable name in my example).
    I also assume that you want each part in a separate variable (City, Provence, Postal Code).

    After your extract step, insert a Try Step followed by a Test Variables step.  Test if nextline contains Alberta.  If Conditions is Not Satisfied, change Error Handling to Try Next Alternative at Nearest Try Step (or whatever you named your Try Step if you are in the habit of naming Try Steps).  

    If the nextline did not pass the Test Variables, the robot will go down to the next branch.  Insert another Try Step to see if the variable contains British Columbia.  Use the same error handling (you can copy the 1st try step and change the condition).

    Add branches after the try step and insert a Test Variable step and test for all Provences. 

    Each nextline Provence that will pass one of the tests.  That is the key for everything that follows.

    To get the Postal Code, insert an Assign Variable.  Assign the Variable to Postal.  In the Value, select the converter.  Get the nextline variable.  Then add Text Formatting, Replace Pattern.    Pattern could be as simple as .*(.......) which will change Edmonton Alberta T5K 2T8 to give you T5K 2T8

    To assign the Provence, well, since you just passed the Test Variable, you can simply use an assign variable.

    To get the City, insert an Assign Variable step.  Choose your City variable for the variable,  In the Value, select the converter.  Get the nextline variable.  Then add Text Formatting, Replace Pattern.    You could use a pattern like (.*)Alberta.*  This pattern would convert Edmonton Alberta T5K 2T8 to Edmonton.  Of course, for each line you would need to use the Provence Name to pattern out the city portion.
    avatar
    News24


    Posts : 12
    Points : 3833
    Join date : 2014-06-02

    Help with divide lines Empty Re: Help with divide lines

    Post by News24 Thu Sep 25, 2014 2:24 pm

    Canada has 13 provinces.
    I should create pattern for each provinces.
    But this is Canada.
    What about USA?
    I need create 51 patterns? very time-consuming if I have several robots...
    Shyam Kumar
    Shyam Kumar
    Ranks


    Posts : 113
    Points : 4342
    Join date : 2013-07-05
    Location : Kerala, India

    Help with divide lines Empty Spliting Issue

    Post by Shyam Kumar Thu Sep 25, 2014 11:51 pm

    Please explain which one is the State name and City name, All are Canada address, can you please share full address part and please mention how you need to split with example
    avatar
    News24


    Posts : 12
    Points : 3833
    Join date : 2014-06-02

    Help with divide lines Empty Re: Help with divide lines

    Post by News24 Tue Sep 30, 2014 8:23 pm

    Shyam Kumar wrote:Please explain which one is the State name and City name, All are Canada address, can you please share full address part and please mention how you need to split with example
    Help with divide lines 062211
    jking
    jking


    Posts : 103
    Points : 4051
    Join date : 2014-03-01
    Location : USA

    Help with divide lines Empty Re: Help with divide lines

    Post by jking Tue Sep 30, 2014 8:45 pm

    How is that data being accessed?  Is it a web page?  Spreadsheet?  What is your end goal?  Are  you extracting the data into variables?  

    Your initial question posed was how to split city and state name (for example from Edmonton Alberta T5K 2T8), but from the new post it appears that City, State/Provence and Postal Code are in separate columns.  I would not expect that one would need regexp or a Kapow Assign Variable with a replace text using pattern to 'separate' the City and State/Provence when the screenshot you posted looks like the City and State are already in separate columns and not in a text string.  

    I'm at a bit of a loss on how to help without knowing where you are getting the data and what you need to do with it...
    Shyam Kumar
    Shyam Kumar
    Ranks


    Posts : 113
    Points : 4342
    Join date : 2013-07-05
    Location : Kerala, India

    Help with divide lines Empty Re: Help with divide lines

    Post by Shyam Kumar Wed Oct 01, 2014 2:13 pm

    Hi.,

    Me also confused about previous post mention by Jking,
    Jking., wrote:How is that data being accessed?
    Is it a web page?
    Spreadsheet?
    What is your end goal?
    Are you extracting the data into variables?

    There are lots of conditions coming in website based on the sources, Here i give some examples,

    Example 1.
    Help with divide lines F210

    Example 2.
    Help with divide lines F111

    How you are extracted the initial value, May be in a single variable, the above example, if the condition is like example 1 mean you can simply extract the city, state and zip or you can extract full address in to a varibale then you can convert it in to different variables. Here you can utilize the html tags.

    But in example 2 full address in a single tag, so its very difficult to split, because we can't give a proper patterns for splitting city, state and zip. Because may be city is a single word or more than one, likewise state also, so we can't predict a common pattern.

    Here i am giving some examples,

    North Vancouver British Columbia V7M 2J3

    In the above address zip is always having a common pattern, So you can extract full address in to a single variable and first extract the zip using a common pattern like,

    .* (\w\d\w\s\d\w\d) or .*?(\w*\s\w*)

    Now you got the full address in a variable, zip in an another variable, then need to extract city and state, in the above example 2, we can't give a commen pattern and there is no delimiter for splitting. So i am applying a simple logic for extracting the city.

    Here you can load this URL http://www.whatismyzip.com/ and enter the zip in the search box and find, now we got the full address with delimiter.

    Help with divide lines F310

    From here you can extract city using the delimiter is comma(,) pattern like (.*?),.*

    After that you can replace city, zip from the full_address variable, now you got the state.

    Help with divide lines F410


    I believe this post helps you, if any doubts or suggestions please keep in touch.


    Thanks.
    avatar
    News24


    Posts : 12
    Points : 3833
    Join date : 2014-06-02

    Help with divide lines Empty Re: Help with divide lines

    Post by News24 Thu Oct 02, 2014 5:06 pm

    Shyam Kumar,
    Thanks for the complete answer
    But I have situation like example 2 - address in a single tag without commas.
    Shyam Kumar
    Shyam Kumar
    Ranks


    Posts : 113
    Points : 4342
    Join date : 2013-07-05
    Location : Kerala, India

    Help with divide lines Empty Re: Help with divide lines

    Post by Shyam Kumar Mon Oct 06, 2014 9:36 am

    I believe now you solve the problem, above i mention the solution also, Please try it, it will work properly..

    Sponsored content


    Help with divide lines Empty Re: Help with divide lines

    Post by Sponsored content


      Current date/time is Wed Nov 13, 2024 2:02 pm