DataTable変数dtの0-11列を一括削除したいが、構文を至急教えてください。

UiPath Studio Enterprise Edition最新版ユーザです。
DataTable変数dtの0-11列を一括削除したいが、構文を至急教えてください。
DataTable変数dtの0-11列を一括削除したいが、構文を至急教えてください。
DataTable変数dtの0-11列を一括削除したいが、構文を至急教えてください。

Hi @gorby

Assign dtColumns = Enumerable.Range(0, 12).ToArray()

For Each columnIdx in dtColumns
    Remove Data Column
        DataTable = dt
        Index = columnIdx

Hi @gorby

You can use the below linq expression

- Assign -> YourDataTable = YourDataTable.AsEnumerable().Skip(0).Take(11).CopyToDataTable()

Hope it helps!!

invoke methodアクティビティを使うとどうなりますか?

Hi @gorby

Can you try the following?

dt = dt.AsEnumerable().Select(Function(row) row.ItemArray.Skip(12).ToArray()).CopyToDataTable()

Cheers!!

You can also use invoke method but simply use assign activity by using linq expression to delete the required rows. @gorby

Your suggestion seems to have syntax error…

Your suggestion seems to have syntax error…

Can you share me the error what you are getting @gorby

How can I replace mydatatable Name?

@gorby

How about this?

Invoke Code:

Dim columnsToRemove As Integer() = Enumerable.Range(0, 12).ToArray()

For Each columnIndex In columnsToRemove.Reverse()
    dt.Columns.RemoveAt(columnIndex)
Next

Input:

Output:

Cheers!!

Hey @gorby

You can use the below linq expression to delete the rows. I have already tried with this it’s working.

- Assign -> Datatable = Datatable.AsEnumerable().Where(Function(row, index) index <  Or index > 11).CopyToDataTable()

Hope it helps!!

Thank you for your reply! I confirmed this code works.
Could you modify this code to remove column 0,3,6? (Not to remove column 0-11 sequentially)

Dim columnsToRemove As Integer() = Enumerable.Range(0, 12).ToArray()

For Each columnIndex In columnsToRemove.Reverse()
dt.Columns.RemoveAt(columnIndex)
Next

@gorby

Could you please try with this

Dim columnsToRemove As Integer() = {0, 3, 6}

For Each columnIndex In columnsToRemove.Reverse()
    dt.Columns.RemoveAt(columnIndex)
Next

Regards,

1 Like

Thank you for your reply! I confirmed this code works as well!

Please mark the appropriate post as solution @gorby

I had already marked your answer as approriate one. Pls check it.

Thank you for your answer!
However, I noticed I could achieve my goal by iterating “remove row activity” twelve times at 0 index…

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