How to retrieve the correct data in the data table and typed it into the value for Type Into activity

Here is the scenario.

I have a tsv file with data and it was stored in a data table.

Sample data in data table (sample_dt)
|Column1|Column2|Column3|Column4|
|DataA1|DataA2|DataA3|DataA4|
|DataB1|DataB2|DataA3|DataB4|
|DataC1|DataC2|DataC3|DataC4|
|DataD1|DataD2|DataC3|DataD4|

Then I have a do while activity where in I needed to input data in a grid.

In the first loop:
The values that will be getting are the data from row1 and row2 since they have the same value for Column3 (DataA3)
|Column1|Column2|Column3|Column4|
|DataA1|DataA2|DataA3|DataA4|
|DataB1|DataB2|DataA3|DataB4|
|DataC1|DataC2|DataC3|DataC4|
|DataD1|DataD2|DataC3|DataD4|

First loop the grid should looks like this:
| |Grid1 |Grid2 |Grid3 |Grid4|
|row1|DataA1|DataA2|DataA3|DataA4|
|row2|DataB1|DataB2|DataA3|DataB4|

then after saving it, the next loop for the grid should look like this.
| |Grid1 |Grid2 |Grid3 |Grid4|
|row1|DataC1|DataC2|DataC3|DataC4|
|row2|DataD1|DataD2|DataC3|DataD4|

Can someone help since I always get the first and second row data from the data table during the second loop?

I hope the scenario is clear as I don’t have the rights to upload to embed screenshots.

Thanks!

Hi @_waysi ,

Is this what you were looking for?

image

dt_sampleData.AsEnumerable().GroupBy(Function(g) g("Column3").ToString.Trim).Select(Function(s) s.CopyToDataTable()).ToList()

Listoftables.xaml (10.1 KB)

Kind Regards,
Ashwin A.K

1 Like

I’m sorry how about if the data that needs to be entered doesn’t have header as it came from TSV file?

I can’t do this part “(Function(g) g(“Column3”)”

dt_sampleData.AsEnumerable().GroupBy(Function(g) g(“Column3”).ToString.Trim).Select(Function(s) s.CopyToDataTable()).ToList()

Is there another way?

Hi @_waysi ,

If the indexes remain constant, then you can use this instead:

dt_sampleData.AsEnumerable().GroupBy(Function(g) g(2).ToString.Trim).Select(Function(s) s.CopyToDataTable()).ToList()
1 Like

Thanks! However, I’m getting this error “Option strict on disallow implicit conversions from “Object” to “System.Data.DataTable” uipath” when using For each row in data table :frowning:

I’ve set the table in the “In” in foreach row in data table activity

Hi @_waysi ,

Could you check if the Type Argument provided under For Each Activity is System.Data.DataTable?

image

image

Listoftables_v1.xaml (10.4 KB)

Kind Regards,
Ashwin A.K

1 Like

Thanks for the help. Will try this again :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.