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?
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. dtOut.Rows.IndexOf(row)
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.
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?
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
or 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.
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.
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.
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.