i_dt_Datatable3からDataRowの配列arr_DataRowを作成したい。

こんにちは。
UiPath Studio 2024.10.0 Community editionのユーザです。

1.やりたいこと

下記のi_dt_Datatable3からDataRowの配列arr_DataRowを作成したいです。

arr_DataRowの仕様は以下の通りです。

※最初にi_dt_Datatable3の(“Status”)="〇"の行を抽出し、i_dt_Datatable3の(“Date”)でグループ単位にする。

i_dt_Datatable3
[Date,Start,End,TimeSpan,Status
2024/06/06,06:58:14,06:59:54,00:01:40,〇
2024/06/06,12:14:53,12:16:16,00:01:23,〇
2024/06/06,13:00:01,13:01:21,00:01:20,×
2024/06/06,15:01:55,15:03:24,00:01:29,〇
2024/06/06,15:49:52,15:51:10,00:01:18,〇
2024/06/06,16:01:02,16:02:21,00:01:19,〇
2024/06/06,16:25:49,16:27:04,00:01:15,×
2024/06/07,06:58:14,06:59:54,00:01:40,×
2024/06/07,12:14:53,12:16:16,00:01:23,〇
2024/06/07,13:00:01,13:01:21,00:01:20,〇
2024/06/07,15:01:55,15:03:24,00:01:29,〇
2024/06/07,15:49:52,15:51:10,00:01:18,〇
2024/06/07,16:01:02,16:02:21,00:01:19,〇
2024/06/07,16:25:49,16:27:04,00:01:15,〇
]

2.相談したいこと

代入文で下記の自動修正前の文字列を入力したら構文エラーとなり、自動修正したら、自動修正後の構文に自動修正されました。意味不明ですが、自動修正後の構文で大丈夫でしょうか?

自動修正前
arr_DataRow=i_dt_datatable3.AsEnumerable.Where(Function(r) r("Status").ToString() = "〇").GroupBy(Function(r) r("Date").ToString.ToArray

自動修正後
arr_DataRow=i_dt_datatable3.AsEnumerable.Where(Function(r) r("Status").ToString() = "〇").GroupBy(Function(r) r("Date").ToString).SelectMany(Function(g) g.ToArray()).ToArray()

@gorby

Everything looks correct I believe ypu need to use g instead of g.ToArray inside selectMany

That should work as you wanted

But one thing here… the groupby will be neutralized once you selectmany as groupby will be split into individual again

Cheers

Hi Thank you for your reply!
Is your suggested syntax as below?

arr_DataRow=i_dt_datatable3.AsEnumerable.Where(Function(r) r("Status").ToString() = "〇").GroupBy(Function(r) r("Date").ToString).SelectMany(Function(g) g).ToArray()

Could you elavorate on what you said or interpret to easier expression ? Hardly understandable.

@gorby

Say you have 2 rows with same date and status as 0…as per your statement the two rows will come as two different rows only at the end…there is no effect of groupby as you are grouping it but again using selectmany…

Ideally the expectation of a group by is that as date is same you should get only one row but as you are using select many you would get two rows still…

I hope this clarifies…

The above formula is correct…try to run it and check the output you would understand what I am trying to say…

Cheers

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