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?
best regards,
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.
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 CSV
read from file
file
Output to
Company_Names (Variable type: DataTable)
Then
Add Data Column
Column Name :
Company_Name (Variable type: String)
Then
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?
Onwards:
For Each Row in Data Table
For Each => Row In => Company_Names
Sequence
Body
Use browser Edge ect.
Do
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?
Pic 1.
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:
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