Using LINQ I did group by. But all the data is in one data table. How do I get multiple data tables for each group? How do I convert each data table to a CSV string? And how do I convert the CSV back to a datatable.
I would suggest converting data tables to JSON instead of CSV. I’ve faced issues with parsing CSV because there are chances that delimiters might be present within the data itself.
Lets assume a simple GroupBy LINQ returning a list of DataTables, representing each the grouped data
Assign Activity:
TableList | List(Of DataTable) =
(From d in dtData.AsEnumerable
Group d by k=d(0).toString.trim into grp=Group
Select t = grp.CopyToDataTable).toList
with: Select t = grp.CopyToDataTable
the DataTable from the group is prepared for the projection
Output DataTable Activity OR
Write CSV File Activity - read resulting CSV as Text OR
Custom CSV conversion OR
Generate DataTable Activity OR
Read CSV File Activity OR
Custom CSV Parsing OR
we can exploit JSON very successfully. In case of DataTables we should keep in mind the caused string length overhead, given by the nature of JSON
can be handled within CSV when surrounding the text with a quote:
Depending on how JSON parsing is setup we also keep in mind for some scenarios
given - column with mixed datatype (Object, “ABC”, 123…)
As with the first row col value the column datatype is derrived, it can also lead to failures within the parsing as 123 is not accepted as string (it is number)
@A_Learner
just get familar with the essential building blocks, then combine all factors as you do need