Hi all,
How can I do a for each row activity that only works for a row that contains specific word/character?
Thanks!
Hi all,
How can I do a for each row activity that only works for a row that contains specific word/character?
Thanks!
HI @jasperlzx,
Use for each row activity
use if Condition
String.join(",",row.ItemArray).Contains("yourvalue")
if true do your operations else leave it go to next record.
Regards,
Arivu
Hello,
Can you be a bit more specific? The word/character can be in any column or a specific column?
If itās a specific column, you can put an If activity inside the For Each Row activity and put the following condition:
row.Item("ColumnName").ToString.Contains("word")
If itās any column, inside the For Each Row you can put a For Each activity and iterate through datatable.Columns
and inside this loop put the If activity with the following condition:
row.Item(column.ColumnName).ToString.Contains("word")
, where ācolumnā is the current iteration of the datatable.Columns
loop.
If you want to extract all rows that meet this condition and only iterate through these for further processing, you can use LINQ
to obtain the rows:
datatable.AsEnumerable().Where(Function(x) x.Item("ColumnName").ToString.Contains("word")).ToArray
hi, this does not work.
hi, its usually in column A. its every 6/7 row after one other but I do not have column header
You can also give it the column index if you donāt know the column name. If itās the first column then the index is 0:
row.Item(0).ToString.Contains(āwordā)
@jasperlzx If you are aware of which column you need to look into, you can filter your data table and get only rows that have required value and then loop through only those rows for further processing.
filteredRows = yourDataTable.Select(ā[Column_Name] like '%ā + Character/WordToCheck + ā%'ā)
user for each to loop through filtered rows
can U show an example? I donāt have a column name as the column also contains data that are not related.
Hereās an example: ExcelWIthoutHeader.zip (8.3 KB)
@jasperlzx Is its possible to share the data in excel and specify what you are looking in that?
sorry I canāt share the file. I just need to location the word, āemployee nameā, and take the 6 rows till the next āemployee nameā. thanks.
@jasperlzx Here you go SearchDataTable.zip (7.8 KB)
Hi some one help me to do the same for a number instead a word for the above case. i used filter wizard and able to achieve this. but i would like to try with For each and if. Example : student record. specific column name : Age.
for all the rows where age is more than 10 , then a specific sequence need to get executed.
I created variable as āAgeā data type string. then if condition didnāt allow to use Age>10. since 10 is different data type.
If i use int32 or double same error while comparing in IF
if you are trying to compare within the for each loop, try checking
(Convert.ToInt32(row(āAgeā).ToString) > 10)
Hi how would I sort if I am just looking for rows that Start with 4 Alphanumeric charcters
this worked