Hi Experts,
As in the title, I want to iterate a data table, get specific columns from a dataRow, assign them to another dataRow variable then add it into a new data table. Do you have any reference?
Thank you.
Hi Experts,
As in the title, I want to iterate a data table, get specific columns from a dataRow, assign them to another dataRow variable then add it into a new data table. Do you have any reference?
Thank you.
hi @D_Okthree
You can select on the basis of some condition for eg:
The records are stored in SelectedData
FilteredData= SelectedData.asEnumerable().Where(Function (x) x(“Column Name”).toString.Equals()/Contains()/SomeLogic())
This would be an array of DataRow
Hi @adiijaiin ,
Here, I am using For Each for data table. So, I will look for the columns from a temporary dataRow variable.
Hi
To get specific row from a datatable as Datarow
dt_row = dt.Rows(rowindex)
Where dt_row is a variable of type System.Data.Datarow and rowindex starts from 0
To get specific column value from a Datarow
str_value = dt.Rows(rowindex)(“your column name”).ToString
This is how you get individual value
Then you can add the Datarow to a datatable with ADD DATAROW activity where pass the first Datarow variable as input
To know more about datatable refer this thread
Cheers @D_Okthree
If you are looping based on For each Row, that currentRow Variable or Row Variable is already a DataRow Type variable you can create a tempDataRow var = CurrentRow, based on condition.
If you wanna access Columns later: just write tempDataRow(“ColumnName”) to access the value.
Thanks
To get specific value from a Datarow mention like this
str_value = dt_row(“your column name”)
Cheers @D_Okthree
Hi @Palaniyappan ,
How to get several columns? Is it like str_value = dt_row(“column name1”)+ dt_row(“column name2”) then assign str_value to a dataRow variable?
sounds also as you interested on a subset of columns from a datatable
dtData: (3 columns)
Defining the Subset of columns:
Extracting the colset
That is also captured here under point 8.
If you want specific multiple group of columns from dt
dt = dt.DefaultView.ToTable(FALSE, "Columnname-1", "Columnname-2", "Columnname-3",….., "Columnname-N")
If you want to specific or multiple group of columns from dt with distinct records
dt = dt.DefaultView.ToTable(TRUE, "Columnname-1")
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.