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.
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
cheers
Hi,
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)
Regards,
Thank you very Much it worked.
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 .
The csv should be read using headers box uncheck then it would
Happy Automation…glad the issue is resolved
Cheers
ok Anil .
I will try that as well.
Thanks for your reply.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.