How can the robot extract all the row value when match some condition in each row, and get all the row value at once.
Please can you help?
I suppose you are trying to process an excel sheet or something similar right?
So what you can do is, read the data to a datatable variable. If your source is a excel file, you can use Read Range activity to read the data to a datatable
2. Now, use a For Each Row activity to loop through the datatable which you used to extract data
3. Within the For Each Row activity, you can use IF activity to match the records with a condition. So the IF activity condition should look something similar to this
row("ColumnName").ToString.Equals(<Your Match value/ variable should come here>)
in your dataset, if you don’t have a column name, then you can use the column index.
row(0).ToString.Equals(<same as before>)
If these are not string values which you are trying to match, you can try converting them to the required format. Let’s say its a number of Int32 format
Int32.Parse(row("ColumnName").ToString) = 1234
Hope this helps!!
- Read the data from Excel using Read Range Activity and will give you output as dataTable.
- Then apply select query on that DataTable.
DataTable requiredRows = dataTableName.select("[ColumnName] = ‘Value’ AND [ColumnName] = ‘Value’ ").CopyToDataTable
It will fetch all matching rows from given input dataTable and will store result in new dataTable say ‘requiredRows’.
I have used read range, and gave if condition, row(0).tostring =“text” and then I want to get whole value of that row, and I don’t use column name.
You can access values in two ways either using Column Name or Column Index.
Here, you used row(0) means you are referring First column in the Excel file.
ForEach row in DataTableName Int index = DataTableName.Rows.IndexOf(row) + 2 If row(0).Tostring = "Text" Then: DataRow dr = DataTableName(index)
Note: If you don’t have Column headers in your excel file, then write ‘+1’ instead of ‘+2’.
I got some error sir, please can you help me.
Don’t write Index.ToString
Assign, DataRow = details(Index)
your condition and the workflow before if condition is fine buddy
i hope you are getting the index of the current row from the for each row loop and assigning it to a variable named Index…
let me tell you why you got this error first buddy @James90
–To get a particular row from a datatable we use to mention as datatable.Rows(Index of the row)
– where the index of the row argument passed above should be type int32
–as you were trying to convert the int32 to string, it was throwing error buddy and then we missed out Rows method rather passed like details(Index.ToString), actually it should be like below buddy
–so to get the whole datarow and assign it to a datarow variable of yours named DataRow
use like this buddy in your assign activity @James90
DataRow = details.Rows(Index)
this would give the whole row after validation done in if condition part buddy
Kindly try this and let know buddy @James90
It’s the same error.
Could you please go to that blue exclamatory mark and show me what is the exact error. So that i can help you in this.
I have made Index as Int32 put the DataRow = details.Rows(Index) also but having error again.
Here is the screenshot of error
Make sure DataRow should be variable of type System.Data.DataRow. But you declared it as "Generic Value’. Change it and then try.
Buddy kindly change the datatype of Datarow variable to system.data.datarow…
The error occurred because we were trying to assign a datarow type to generic…this is what is mentioned in the error pop-up as well… buddy
You were almost done
Kindly try this and let know whether this works or not buddy
Buddy i think you were trying to assign or used write line activity to print or pass the valuebof Datarow variable…
When you do that we need to mention the index argument as well like this
Where 0,1,2…are columnindex buddy
Yes, we can’t print that DataRow directly. You have to print either passing Column Name or Index to DataRow.
DataRow(“ColumnIndex”).Tostring or DataRow(“ColumnName”).Tostring
Were you able to get now buddy @James90
I think we are having miss communication, here what the robot does is that, it check one column and if the condition is fulfilled then it will take all value of the same row. Like, When Robot compare column 4 of date, if date condition is fulfilled then how to get all the data of its same row(highlighted)?