How do I group similar data into separate files?

Hi,

I have an excel sheet like this
image

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

in general it is about grouping the data on the category:

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.

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,