Writing data table values to a new data table?

Hey there,

I have a DataTable of scraped items from a portal, however, there are some which will not be required. I therefore want to write the required items to a new Data Table so I can filter out the ones I don’t need.

How would I go about writing these to a new table? I tried a ‘for each row’ with an ‘if’ activity to select the items I wanted, however, it tells me that it cannot write to a new DT if iterating through another.

Any help would be appreciated, thank you!

Hi @dr1992

You can try ‘Filter data table’ activity & provide the conditions based on which you can obtain the desired result. Also, you can use LinQ query to achieve the same.

Cheers

Unfortunately, filtering will not be an option based on some specific needs I have of this build (it is quite complicated to explain aha)

You can make use of LinQ queries in that case. You can directly use both Assign activity or Invoke Code activity to implement the LinQ.

Hi @dr1992,

If you want to get less no. of columns only and of course specifc rows then you can Build A new DT with those columns name and inside your for each row for a condition; use Add data Row.

In ArrayRow property put {CurrentRow(0).ToString, CurrentRow(1).ToString…} so on.
These no. of elements inside { } should be equal to your New DT’s column count, and you can use different Index to take columns value from original DT.

Let me know if it helps.

Hey,

Am I doing something wrong with the filter wizard here? I essentially need to remove the row (of column 0) if the value is a set variable or the bottom text. I ran it, it doesn’t error, but it also doesn’t remove it.

Any ideas?

image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.