Using For each row and scanning through each row

I am using a Read CSV to read through a small database and storing the output of CSV as dtOut.

Then, I want to read each row of that datatable (read each row of column A, headers are there). Store the value in that cell as a variable and then use that variable in the further process.
I have assigned variable issueNo to (dtOut.Rows.IndexOf(row(1)).ToString). It says that it disallows implicit conversions from Object to “System.Data.DataRow”

What am I missing here? Is there any other better method to do what I need to do?

Please help.


If you are looking for the index of the row, then you want to use a DataRow. You are trying to use the index of an item in the row, so just remove the item index.

That will return an integer. Or add the .ToString if you wish to use a string, but I normally would use it as an integer.


1 Like

Thanks for your reply. I tried what you suggested. The errors vanished, but when I run the workflow, it gives me this error. “A column named 10/15/2018 already belongs to this DataTable”. I am unable to understand what this is all about. What is this?


I’ll also add a few more helpful things.

To store items from a particular row, like in a For each for example, you really only need to use either an Assign activity (my preferred method) or the Get row item activity.

You just need the column index or column name.

For Get row item, you need to fill out these properties:
You can put row in the Row property, then use either the Index or the Name of the column to extract a particular item and store in the Value property

If you want to use an Assign activity, then you can set it up like this:
variable = row("columnname").ToString
variable = row(index).ToString
And you can also do some manipulation to the value if needed within the same Assign activity.

Get the .IndexOf() of the row during the For each is only beneficial if you would like to skip to that item at the start of the For each, in the event you exit out to a Catch then reenter that For each again. Or you can use that number for analytics to store the index that is being processed. However, you can’t really use that index for extracting items of a particular row.

Hope that bit of info is helpful.


You can add it to collection using “add to collection activity”. In input you can give row(0).tostring. And, you need to initialise the collection before using it.

You can use the collection in future :slightly_smiling_face:

We would have to see some more of your code. If you are using a Add Data Column, then maybe that’s why it is giving you that error.

I am not using Add data column. I have attached an image, I am trying to get this part working before I can attach this to anything else.

Please check if there are two columns with the same name “10/15/2018”

Do you have the AddHeaders property selected on the Read CSV? Maybe the file has no headers?

1 Like

Yes! You are right. Actually, I had removed the headers and only kept the data to skip headers. If I keep the headers, is there any property I need to enable for it to understand the difference between Headers and data? I cannot see any such checkbox.

1 Like

The file does not have headers. But, I cannot see the AddHeaders property on the Read CSV activity either.

It’s called “IncludeColumnNames” for Read CSV. So unchecking that should assume the file has no column headers.

But, to determine if the file has headers or not is more tricky, so typically we assume the file will either have headers for every file or no headers for every file. I suppose you could store the headers in an array or something similar then check the first row, and if it matches, then use a Read CSV with column names.

The row numbers should be put as integer? Or is there a command to it. When I tried to put it as 1 or 2… so on, it threw an error over there. “Value of Integer cannot be converted to System.Data.DataRow”

When you use the Get row item activity, it requires a DataRow object.
For example the ‘row’ in For each row in dtOut

Then, change the ColumnIndex or ColumnName property to extract a specific item in the row.

Hope that answers it.

So you don’t really need the index of the row, unless you need it for certain things like calculating a Range in an Excel file or just simply knowing which item has being processed as a number. But, to extract values from the row, you don’t need it.


What do you mean by chaging the property? My current workflow looks something like this. I think I am not understanding what"DataRow Object" means

In get row item, you need to give row property as “row”, index=2, output value=IssueNo