Split street, City,state,zipcode from Addresss and load it to the database

Hello Team,

I was using web application to get the data from site and splitting the whole address to different column as street, City,state,zipcode from Addresss and trying to load.
But facing issue like when i tried split through comma and space delimiter it is not giving correct.
For Example: address as “84 8th Street, San jose, CA 91111”
is working correct but address as “512 4th Street,Unit2, San jose, CA 81234”
is not working correct
so any help will be appreciated and also for each used is not working when i run the file but when i try to debug file with breakpoint in for each it will load but give above error “unit2” is also there in the address.

Thanks

Try searching the address on Google Maps.
It will likely give you one of these options:

  1. Matched address in a consistent, comma-delimited format
  2. Partial matched address with the suggested address in a consistent, comma-delimited format
  3. No matches

There is a convenient copy address button as shown in image below:

Hi @jezna_jose ,

  1. Add an activity to read the address data from your data source, such as an Excel file or a database.
  2. Use the “Matches” activity from the “UiPath.Core.Activities” package to apply the regular expression pattern to each address string.
  3. Configure the “Matches” activity by providing the address string as input and the regular expression pattern as the pattern to match.
  4. Iterate through the matches using a “For Each” activity to process each address part captured by the regular expression.
  5. Inside the “For Each” loop, you can assign each captured address part to the appropriate column in your data table or perform any other required processing.

Regular expression to be configured in matches activity,
^(\d+\s+[^\d,]+),?\s*(.?),\s(.?),\s(\w{2})\s*(\d{5})$

Please try and let me know if you need any help.

Hello @Gautham_Pattabiraman ,

  1. I am fetching data from web and used extract table data and stored the data in datatable.
  2. Extracted data have one address column which i need to split as street, city, state, zipcode.
  3. Inside For each loop ,I am splitting the address with comma separate it worked fine but for some it have extra details like “ 4th Street,Unit24, Beach, FL 90245”
    which causing error
    .5. Using regular expression mentioned , how to do that

Hi @jezna_jose ,

Now i understand that the problem is with the extra data for this row item.

Use the below regex,
^([\d\s]+[\w\s]+),\s*([^,]+),\s*([A-Za-z]{2})\s+(\d{5})$

In input properties,

Enter the above expression in pattern field.

Pass the string or in case of row item convert to string in the field text to search in.

Finally in the output property of match activity click on the field and using ctrl + k to create a variable that will store the pattern matching object collection obtained from our input string.

My sincere suggestion would be,

Create a test sequence assign the string with the value you want data extracted from

Configure matches activity.

Use a loop and print the values in the output collection of matches activity and check if it is returning correctly.

Test it with a case where there is no unit information and with one which has the extra detail.

Once you make sure this works, you can use the code inside the module where you actually want it to be.

You can use the input properties to configure the Matches activity.

The above link will help you learn more about matches activity.

Hope my inputs are helping you out.

Happy automating.!

Thanks,
Gautham.

Hello @Gautham_Pattabiraman

I have string variable with an address value and in the match activity added the pattern as well
Then in the For each try using log message but not working as expected

Hi @jezna_jose ,

My Apologies , it didn’t work as expected. Attaching an alternative Method for extracting the info from a string. Please check and let me know if you need any help using this in you current module.
TestProcess.zip (3.3 KB)
Hope this helps you out.
Note : Have Preset the values(Addresses provided in this thread) in Assign activity comment and uncomment those to check diff cases

Thanks,
Gautham

I’ve had the same issue trying to parse addresses from Purchase Orders.

Regex doesnt work cause of the variance in format, we tried a deep learning model for parsing an address but got inconsistent results.
In the end we found the most effective method was to leverage an LLM, with its contextual understanding its able to recognize things like Unit 2 and parse it appropriately.

I’d suggest implementing an LLM to parse the address.

1 Like

Hello Gautham,
Thank you but it will work in only unit case,if any other word comes it wont work.
Any way of assigning last to first like from zipcode fixed and then state and then city and then rest all street.

Hi @jezna_jose ,

Understood. Attaching a workflow that uses length of the array instead of checking for key word (Unit).

Please check if the attached workflow helps you out.

TestProcess.zip (3.5 KB)

Thanks,
Gautham

Hello @Gautham_Pattabiraman,
Thank you so much. It worked but One small thing, the data i am taking is from web and used datatable to store the data from web.
And then used for each loop and inside that for address, i have used switch and rest column directly assign to a variable which further using “Build Data Table” and made a connection to the database to load the data to a table in database.
I am using all this and when i run debug file , it will fetch from web and from “For each” it is not working but when i add breakpoint at for each, it will work and so do i need to add slow step any activities since it need to fetch the data from web and pass the data and do the array manipulation and then assign to variable which further loaded to database.

Hi @jezna_jose ,

If possible kindly share a screen shot of the for each loop.

Thanks,
Gautham.

Hello @Gautham_Pattabiraman
These are the screenshot

Hi @jezna_jose ,

Add an assign activity before the first multiple assign.

LHS :
Variable of type String array (StringArray)

To hold the splitted parts of the value.

RHS :

CurrentRow(“ColumnName”).Tostring.split(","c)

ColumnName - Replace with the column name that holds the address in the data table which you are iterating.

Note : The variable created in the above step should be referred to in the multiple assign.

Hope this helps you set it right.

Thanks,
Gautham.

Hello @Gautham_Pattabiraman ,

I have already given like that

Then in the switch

Case 3 and case 4 for address Then build data table,multiple assign for rest of columns(other than address), Add data row to datatable and then insert to the database

This is working as expected in debug mode, when given breakpoint on “for each loop” and selecting slow point (1*)
but when i try to the run that using “run file” without breakpoint, it will fetch the data from site only but not going to for each and end the process.
Is this because i need to add any slow activity or wait activity in the for each or before that, so that it will run in the "Run file " mode.

Thanks

Hi @jezna_jose ,

I understand your issue now. If it is running fine in debug mode then it must be fine in run mode also.

Try adding a delay before the for each loop and add one log message to check the number of rows the data table has.

And one more suggestion is to use the reference as row instead of current row in for each activity.

Please try the above and let me know if it still persists.

Thanks,
Gautham.

Hello @Gautham_Pattabiraman ,
I have done the changes it was working fine but when tried after sometime i need to reinitiate the web target and anchor and now i was counting the row fetched added that activity as well but showing 0 and it end the process

Thanks

Hi @jezna_jose ,

I am unable to interpret, Could you please share some snapshots.?

Also, Place a breakPoint before the suggested string manipulation starts, Check if the Orginal String Variable which has the address (UnSplitted) has a value or not.

Looking forward to helping you find a fix.

Thanks,
Gautham.

Hello @Gautham_Pattabiraman
Thank you so much for helping. Really appreciated.
I have done the changes it was working fine in “debug mode”. Without breakpoint it is working in Debug mode but sometimes i need to
“edit the target” or “Indicate target on screen again” like below or reinitiate the

image

And now encounter new error below when inserting to the database table

image

Hi @jezna_jose ,

Please share the properties configured to the type into activity, I presume that you are trying to enter one of street/city/pincode.

Thanks,
Gautham.