I have a CSV file that has 550 columns I want split this to 10 tables. How can we create multiple data tables from single table. Please help

Hi @ssk,

it depends on how you want them split? Do these need to split by certain row increments or by column increments.

e.g. columns A - D and then D-F etc OR all columns but rows 1-10 and then 11-20 etc.?

Either way I would possibly using a looped read range to read into separate datatables.

A brief google for “VBnet split datatables” shows several possible answers if you are looking for a code answer.


You can place an if condition with rows.count<50,<100 … and build datatable with those values

Hi @ssk,

Refer this link

private static List<DataTable> SplitTable(DataTable originalTable, int batchSize)
     List<DataTable> tables = new List<DataTable>();
     int i = 0;
     int j = 1;
    DataTable newDt = originalTable.Clone();
   newDt.TableName = "Table_" + j;
    foreach (DataRow row in originalTable.Rows)
         DataRow newRow = newDt.NewRow();
         newRow.ItemArray = row.ItemArray;
         if (i == batchSize)
          newDt = originalTable.Clone();
          newDt.TableName = "Table_" + j;
          i = 0;
   return tables;


I want to split by 50 columns in each data table and I want to do this in UiPath

Thanks for your reply. I want to do this in UiPath

Thanks for reply. I want split in UiPath by column and rows. Like 50 columns and all rows for that columns in a data table.

I have given the process to do itin uipath only using FOr each row,if condition,builddatatable

Hi @ssk,

Yes Its possible follow the same steps in the uipath.


Thanks again. I am new to UiPath so finding it difficult.

With builddata table I was able to create a table with 7 columns but adding data to those columns from source which has 550 columns is the issue. If I use for each row it will get a row will all 550 columns instead of 7 column rows.

Thanks again. I am new to UiPath so finding it difficult to put same thing in UiPath code. I tried using select for getting only few columns but that returns DataRow() and not sure how to declare the DataRow array


Let us take your datatable as dta.
Let us take List of Columns Names List A

ListA=(From p in dta.Columns.CastOf(System.Data.DataColumns)
Select Convert.ToString(p.ColumnName)).ToList

Then Initialise two Integer Variables
intk =1

Now You take the inta =ListA.Count/Int Tables
int Tables The number of Tables you want to Create (For your scenario it will be 10)
Create one more datatable dtb
Then Run While loop by giving Condition(K<=int Tables)
Inside while loop
add one if condition
If False Then use Clear DataTable to clear dtb

Now use below Query to take the columns from a datatable in an incremental Order.


then Increment int n= intn+1 and int K = int K+1

Then use Write Range to Write the DataTable dtb
Give the Sheet Name “Sheet”+intK.ToString



Thank you will try this

Datatable Results_of_two_cols = Yourdatatable.Select().CopyToDataTable().DefaultView.ToTable(False, “Date”, “Close”)
this worked perfectly


You told to create 50 Seperate tables with 10 columns each right.


yes I modified the above code as per my requirement. I got this one from one of the forum.