In a workflow if headers are not coming how to check and solve them.How can I check all column headers in an excel sheet and output the missing columns names and how I can choose the names the bot will search
- Have the columns you want to searched saved in the config or a variable
- Loop through the list of columns and use find/replce activity to check if it is present on excel or not
- Instead of second option you can also read the data from excel into dt and then use
ListOfColumns.Except((From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray()).Count=0
to check if all the required columns are present or not in the datatable read ListOfColumns.Except((From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray()).ToArray
This gives the missing columns if the count is not zero
Hope this helps
Cheers
i have constructed the workflow how to check in the workflow ,if headers are missing in output?
Please use the point 3 and 4…in the workflow I believe you have read the data into datatable …so now create an array of names you wnat to check and use the formula given above to find if all the values are present in the datatable header or not
Cheers
Hi
I think if u can get the list of column names u can understand whether if there is any column missing or column itself is there or not
Use a assign activity like this
List_columnname= dt.Columns.Cast(Of DataColumn)().Select(Function(x) x.ColumnName.ToString).ToList()
Where List_columnNames is a variable of type list of string
To do this u must have a list of column names that needs to be there
It has to be defined by us or saved somewhere so that bot can refer that and compare to this list of columns we have obtained from current datatable
Let’s take u have saved the column names in list_actualNames
Once it’s obtained we can compare like this in a assign activity
list_final = List_columnname.Except(list_actualNames).ToList()
Cheers @anjani_priya
can you keep it like a code
send me the code like a assign activity where the col names should be given
I have shared the expression above
U can keep this assign after reading excel file as a datatable
Then have the list of actual column names and compare that with above expression output
Using a assign activity like this
Once it’s obtained we can compare like this in a assign activity
list_final = List_columnname.Except(list_actualNames).ToList()
ListOfColumns.Except((From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray()).ToArray()
This is the code to be used in assign…output of this is what will give you the array of items which are not present if they are not
ListOfColumns.Except((From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray()).Count=0
This can be used in if condition before the above code to check if all the columns are matching or not… on the then side you have matched columns…on else side you can use the first formula to get all the unmatched rows
Cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.