hi guys, i want to iterate through columns which name contains a certain keyword. i think the best way to do this is by using for each row and use row([column_index]). But how can i find the column index ?
Hey @RobertoEwaldo,
You are halfway.
- Iterate through for-each row
- Have one more for-each inside to iterate through columns of every row
- Add a if condition to check it contains keyword and if condition passed store the index value you get from for-each
Hope this helps.
Thanks
hi @Nithinkrishna,
the keyword is only on the column header
dt.Columns.IndexOf(“Gender”)
hi @ImPratham45,
the column header is not exactly “gender”, something like “aa_gender”, and there is another excel file with column header “bb_gender”. i want to get the index of the columns that contains gender
something like " * gender * "
@RobertoEwaldo
give a try on:
Assign activity:
leftside: ColIndex - datatype: Int32
right side:
dtData.Columns.Cast(Of DataColumn).ToList().FindIndex(Function (x) x.ColumnName.toUpper.Contains("GENDER"))
this works, thanks !
Most Welcome!!!
this works too, but what if there are more than 1 column that contains the keyword ?
it finds first occurence
for getting all indexes we can reformulate. Any specific need like index and found full column name for all columns containing “XYZ”?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.