Hi,
I have an excel sheet like this
I want to be able to group all flowers in one text file, all animals in one text file and all birds in one text file automatically.
Can you please tell me how to go about it? Any suggestions are welcome
Thank You
ppr
(Peter Preuss)
March 16, 2022, 8:59pm
2
in general it is about grouping the data on the category:
This HowTo introduces on the different options for grouping data from a datatable in order to process the grouped data.
Introduction
Grouping data and processing the grouped data is a common scenario e.g. when the grouped data is to aggregate like summing up, find maximum, get the average or concatening items.
Lets have a look on following data:
[grafik]
A possible scenario could be:
Create a report containing following information:
the region code
the sum of CaseCount per RegionCode
t…
Assign Activity:
LHS: TableList | DataType: List(Of DataTable)
RHS:
(From d in YourDataTableVar.AsEnumerable
Group d by k=d(“Category”).toString.Trim into=grp
Select t = grp.CopyToDataTable).toList
For each Activity - TypeArgument: DataTable Values: TableList
iterate over DataTables from TableList
e.g use output DataTable Activity to generate a Text representation of the loop datatable
write it to a text file
Use ‘Read Range’ to read in all of your data as a Data Table Variable. Then use ‘Filter Data Table’ to make a new specific data table, then you can output that new data table as a text file.
Yoichi
(Yoichi)
March 16, 2022, 10:49pm
4
Hi,
Another solution:
In this case, it might be better to store them to Dictionary as the following.
dict = dt.AsEnumerable.GroupBy(Function(r) r("Category").ToString()).ToDictionary(Function(g) g.Key,Function(g) g.CopyToDataTable)
Sample20220317-3.zip (8.8 KB)
Regards,