I have a CSV file which has 2 tables in it. I want to read those 2 tables into 2 different datatable

I have Data in a Csv Files .

There are 2 different table in CSV files.
I want to read both tables in 2 different datatable.
I tried read csv activity but the problem is that if does not have range feature.
please help me to resolve this issue.


You have to read whole csv and then split the table based on the blank row

you can use this to find blank row and use it to split as two tables

FirstTable - dt.AsEnumerable.Take(dt.Rows.IndexOf(dt.AsEnumerable.Where(function(x) x.ItemArray.All(function(y) y.Equals(String.Empty)))(0))).CopyToDatatable

Second Table - dt.AsEnumerable.Skip(dt.Rows.IndexOf(dt.AsEnumerable.Where(function(x) x.ItemArray.All(function(y) y.Equals(String.Empty)))(0))+1).CopyToDatatable



Can you try the following sample? This splits whole string by 2 or more blank lines, then convert it to datatable using GenerateDatatable activity. Finally assign it into dictionary.

arrCsvStr = System.Text.RegularExpressions.Regex.Split(strCSV,"(?:[^\S\n]*\n){2,}")

Sample20230516-1L.zip (3.1 KB)


Thank you very Much it worked.

1 Like

I tried your solution but the problem was there were 2 headers so it was throwing the error. That file has multiple header.
The issue is resolved now I used the solution posted by Yoichi.
Thanks for replying to my Question .

1 Like


The csv should be read using headers box uncheck then it would

Happy Automation…glad the issue is resolved


1 Like

ok Anil .
I will try that as well.
Thanks for your reply.

1 Like

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