Grouped By Data table

Hi,
I have a groped by data table. How to retrieve each group of data from the data table?

Thank you,

Hi,

I have a groped by data table.

What type of variable do you have?

Regards,

@Yoichi

It is a string type. Data table is nicely getting grouped by this string type column. I like to split this data table into multiple based on the group value. Then I do not know how to convert the data table into a csv string to be able to upload to Queue.

Thank you,

Hi,

Can you share specific sample (input and expected output)? It’s no problem if dummy data.

Regards,

Wouldn’t it just be simpler to let your automation directly read the file? Instead of trying to group the data, serialize it, put it into a queue, deserialize it…just put a queue item with the path and name of the file, and let the automation pick up the file.

@postwick
I am not getting how to do this.
I have an Excel file.
What I need to do is group by column name. My transaction item is these bunch of rows.
Each transaction item is bunch of rows.
How can a queue accept this?

Thank you so much,

Why? Why not just have your automation…read the Excel file?

Group the data, generate an Excel file for each group, and put a queue item in for each group with the path and filename.

Data can be like this. There are several other columns.
So I need to act upon the rows with same ID at a time.
Thinking Group by and split into data tables. But how to send to queue
and get from queue.

Name ID …
Rob 1
Mary 1
Josh 5

Thank you,

I keep asking you…WHY send it to the queue? You’re just making extra work. Just write it to an Excel file and then in the queue item put the path and filename, and then have your automation read the file directly.

1 Like

Thank you. This certainly can be done. However, production has lots of data and I am afraid, creating these many excels is like not normal thing to do. But this I can follow.

Regards,

It is very normal to just reference files in a queue item and then have the automation read the file.

Anyway, there are tons of posts already on how to serialize a datatable into JSON. Here’s one:

So the very idea of queues is for collecting metrics in my org. With writing to the excel, I will be losing that prospect. But if there is no easier way out, I will go with that.

Thanks again!!!

That’s really not what queues are for. What metrics are you trying to collect?

@postwick
So it helps further I am asking, is there a way to convert data table to CSV string and CSV string to data table instead of using JSON to upload?

Thank you,

Data usage, success/failure etc.

And I’m not saying don’t use a queue. I’m saying don’t bother putting the datatable into the queue, write it to an Excel file then create a queue item that points to the file.

1 Like

By the way, here’s a method I’ve used to group data before.

For Each Row in Datatable: myDT.DefaultView.ToTable(true,"Group Column Name").AsEnumerable.CopyToDataTable

What that expression does is give you a datatable of just the unique values in the column you want to group by.
image

Then for each row in that unique datatable you use Filter Data Table to get a datatable from the original:

Now you have a datatable of the group data (DT_Group) and you can do whatever you want with it - write DT_Group to Excel, serialize it into a JSON string (which can be put into a queue item), put it into a dictionary, etc

1 Like

Thank you so much, @postwick
Will do this.

@postwick

Json string - put into a dictionary
Can you please clarify this?

Thanks again,

I already gave you a post on that.

1 Like