Please. Send help. I don’t get why I can’t find the answer to this anywhere.
So context this is what project I’m trying to do:
- Take a single column of company names (220 +) from a CSV file
- Search each company name on google + keyword “ownership” and select the first result
-Copy the url and paste the URL next to it’s original cell
The thing is I’m already stuck on creating a dynamic way for creating and naming a variable while using a for each loop… This is my end goal
I mean, I have to make countless variables right to be able to pass the values from the DataTable to the Type into activity right? I saw someone talk about using a dictionary on another thread but I’ve never used one before. Should I use lists or arrays or Queues or something else?
Is there a reason you are attempting to make a variable for every Company Name in the file? If so, please share a picture of your entire workflow and explain.
Otherwise, try utilizing a single String value companyName and assign each row value dynamically in the loop. You shouldn’t need a separate variable for each company name. Just use one.
No, you don’t have to make a bunch of variables.
Read the CSV into a datatable, say we call it DT_Companies. Now you have a DT with one column “Company Name”
Add Data Column to add a string column named “Company URL” and create a variable named URL
Then you do…
Use Application/Browser to open Google.com
-For Each Row in Datatable DT_Companies
– Type Into CurrentRow(“Company Name”).ToString + “+ownership”
– Click Search button
– Grab first result URL and put into URL variable using Get Attribute or some activity
– Assign CurrentRow(“Company URL”) = URL
-End For Each
I’m pretty sure that this is what I need to get me on the right track, but I’m having slight trouble connecting everything together.
So I start by establishing the data and the datatable it should reside in. I start by getting the data (three items for simplicity) of one column in a CSV file. The goal is to load these three (and eventually more) into a a DataTable [Company_Names] column named Company_Name and then fill up a corresponding column to the right named Company_URL.
read from file
Company_Names (Variable type: DataTable)
Add Data Column
Column Name :
Company_Name (Variable type: String)
Add Data Column
Column Name :
Company_URL (Variable type: String)
My question with this part is, how can I be sure that the column from the CSV file has indeed been ‘unloaded’ into the Company_Name column?
For Each Row in Data Table
For Each => Row In => Company_Names
Use browser Edge ect.
Type into: => Type this: Company_Name.ToString
Here comes the error. Object reference not set to an instance of an object.
If I exchange " Company_Name.ToString " to => “CurrentRow(“Company Name”).ToString” then I get the error : “ARgument ‘Text’: compiler error(s) encountered processing expression “CurrentRow(“Company_Name”).ToString”.‘CurrentRow’ is not declared. It may be inaccessible due to its protection leve.”
I’m really close - I can feel it. It just needs a bit of a work around to make it work. Do have any ideas?
I’m not sure if you have other errors, however in picture 2. it appears you are using the variable Row in the For Each, but variable CurrentRow in your Type Into Activity:
These need to be the same:
This did help! Thank you. However I was still having trouble with passing the correct column CSV data to the column Datatable in UiPath. The column I created using “Add Data Column” was essentially empty, it wasn’t until I replaced the “Company_Name” (aka the name of my new DT column) with the value of the first CSV cell, which ironically was another company name… that it worked. I’m going to solve this problem by having a “name” cell in the CSV file at the top in A1
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.