This is the example output, sometimes there is 1 extra column and sometimes 2.
I want a conditional statement to check the dtInputTable if there are extra columns and remove them regardless if its only 1 column or more.
Thank you
This is the example output, sometimes there is 1 extra column and sometimes 2.
I want a conditional statement to check the dtInputTable if there are extra columns and remove them regardless if its only 1 column or more.
Thank you
Hi @Greggy
You can try with column count
Use Read range activity ā Dt
Use If activity
Dt.Column.Count
Regards
Gokul
HI @Greggy
You will have set of standard column count right? I think you 9 standard columns and 2 unwanted column
So you can try like this
Hope this Helps
Regards
Sudharsan
Iām using this activity, remove data column, it seems that the excess column is not working
How can I remove the excess column dynamically, like what if the excess is 3 columns or 4 moving forward?
Thank you.
we do see the extra columns with the auto generated name ColumnX
Assign Activity
arrExtraColNames | String() - String Array =
yourDataTableVar.Columns.Cast(Of DataColumn).Where(Function (x) x.ColumnName.toUpper().Trim().StartsWith("COLUMN") ).ToArray()
afterwards you can loop over arrExtraColNames and remove the columns with e.g. Remove DataColumn Activity
Hi @Greggy ,
If you do know the Column Names that are required before hand, You could store it as an Array of String and use it with DefaultView.ToTable()
to preserve only the mentioned required columns.
For Example,Considering Name
, ID
, Place
are the column names you would want to keep/Preserve, we could have the array initialised in the below manner :
columnsToKeep = {"Name","ID","Place"}
Now, we could use the below Expression to Filter for only the Required columns :
DT = DT.DefaultView.ToTable(false,columnsToKeep)
Here, DT
is your Datatable variable.