Read CSV, search for on web and write to CSV


#1

Hi all,

I am new to UiPath and trying to build a bit complex scenario, already have gone throug the similar topics but still have some issues.

My scenario:
#1 Read the CSV (clients)
#2 Open link - https://www.un.org/sc/suborg/en/sanctions/un-sc-consolidated-list
#3 Search for a client name (one by one from clients.csv).

  • If any entry found – copy and paste the URL to the same row (next to the client name)
  • If no entry found – write next to the client name - “no match”

Attached you can find my example.

Could you pls look through it and give any advise?
Much appreciated.Test.xaml (23.3 KB)


#2

What issue are you facing? Can you share the client csv file?


#3

I think the variables or activities are not correctly set or linked, since having no results… or maybe screen scraping is not set correctly… as well as dont know how to build the part for writing the results back to csv file

attached xls file (cvs is not allowed to upload)Clients.xlsx (7.7 KB)


#4

Hello.

After looking over your workflow briefly, I can give you a few ideas.

After searching for the client name, you need to do 2 things:

  1. extract the text that determines if the item is found or not
  2. Inside the If activity, use an Assign activity in both sides.
    —if it is found, Assign row(“column”) = url
    —else it is not found, Assign row(“column”) = “no match”

“column” is the column name where you would like to add the url or no match to. If the column does not exist, use an “Add Data Column” right after the Read CSV.

So, essentially you are assigning the value in the column of the row that you are searching. This saves it in the data table (dtContacts). Finally, either outside the loop or inside but outside the If condition, place your Write CSV using dtContacts. —if you place the Write CSV outside the loop, it will update the file after everything is done and is faster —if you place the Write CSV inside the loop it will update each row as you go but might be slightly slower.

In case you are a visual learner, here is a quick screenshot of what you can do:

Regards!


#5

Hey ClaytonM,

many thanks for the explanation… I’ve followed your steps and now having the issue with “write line” activity - once added column to the csv file for results (there are just two columns in csv - Client and Result).

image

Any thoughts how to fix that?
Attaching the updated scenario - Test.xaml (25.1 KB)

Thanks and regards


#6

@MSedlacek Check spaces in column name. That is the problem.


#7

Hey Manjuts90,

checked, there are no spaces… the error occured after adding the second column in my csv file (#1 column is Client and #2 column is Result)

Any other workarounds?


#8

@MSedlacek Check once “Client” column name in ur csv.


#9

checked… if my cvs file has only one column (Client), no error… when added column Result, error occurs


#10

@MSedlacek if Client is first column use row(0).ToString instead of row(“Client”).ToString


#11

thanks, now it works… almost there :slight_smile: but got stuck in assign activity row(“Result”) = AddressdisplayControl… throwing an error - Exception has been thrown by the target of an invocation


#12

@MSedlacek can i sample excel data to check the workflow.


#13

here you go
Clients.xlsx (9.6 KB)

and the workflow
Test.xaml (25.1 KB)


#14

I think the reason your column does not exist when you use “Client” or “Results” is because you are using Read CSV with Clients.csv but your file is Clients.xlsx. You might be reading the wrong file. Additionally, if you read a file that doesn’t include all the columns you want, then simply use the Add Data Column activity to add it in (ie Results, if the Results column is not on the initial file)

It’s up to you, but I recommend using the Column name instead of the column index (0) or (1) just because it allows you to change the order of the columns and not impact your process.

Regards.


#15

Thanks for your post, ClaytonM… actually, the reason why I’ve uploaded a xls file here is that the csv file is not supported to upload… I’m sure that my WF reads and works with Clients.csv file

Anyway, any advise on how to fix the issue with assign activity (row(“Result”) = AddressdisplayControl - not working)?

Thanks and regards


#16

Sure, took a look. AddressdisplayControl is a generic value type, so you need to use .ToString next to it or change the type to a String.

Let us know if that works!


#17

I’m afraid, it does not work… maybe if you would be so kind and try to debug it… would really help me to moving forward


#18

Hi. I didn’t see any errors, although the website just does not work well at all on my end, like it takes a minute just to move from element to element which was challenging.

I did find that your approach to pull the url was not working. I found this out by placing a Message Box to output the AddressDisplayControl.ToString variable.

So what you might have to do is instead use the Get Attribute with the html tag, like shown below:
image

If you have further issues, let me know and provide any screenshots or details if possible.

Thanks.


#19

Thanks ClaytonM for helping me… I’ve tried the suggested approach and the new error occured :slight_smile:

Here is a screen of the problematic part:

And the error
image

Could you pls check it one more time? Test.xaml (24.7 KB)

Many thanks


#20

Hi.

Just making a quick reply on the error you received. It seems like the Attach Window selector does not align with the “partial” selector of the Get attribute.

You could try using the full selector in the Get attribute as a test. To do this, simply select the body of the webpage from either the “Indicate on screen” option (which will give you the correct selector possibly) or in UiExplorer (which will give you the “full” selector; my previous image was only showing the partial selector.

I have not looked into it much further than that.

Hope that helps identify the issue.

Regards.