Splitting data table

Hi All,

I have a datatable of n columns. The value of N can vary. I want to split the data table into two data tables. First datatable will have column 1 to column 5. And the second data table will have column 6 to column n.

This can be done using loop and Remove Data Column activity. However wanted to check if there is any simpler way.

Thanks you!

You can use DataView.ToTable(). E.g.

dt1 = dt.DefaultView.ToTable("table1", True, dt.Columns.Cast(Of DataColumn).Take(5).Select(Function(c) c.ColumnName).ToArray)
dt2 = dt.DefaultView.ToTable("table2", True, dt.Columns.Cast(Of DataColumn).Skip(5).Take(N-5).Select(Function(c) c.ColumnName).ToArray)
1 Like

Hi @Kapil,

You can use filter activities as a simple way of splitting table

To Get the first 5 columns, select the Keep Column option in the output column and give 0-4 column ids
To get the 6-n columns, select the Remove column option in the output column and give 0-4 column ids


1 Like

thank you @ptrobot and @VIDHATHA_THADURI !! I wish it was possible to mark both answers as Solution.