Robotic Process Automation (RPA)

 View Only
  • 1.  Delete Columns

    Posted Thu March 07, 2024 02:52 PM

    Hi, I'm trying to delete more than one column from a DataTable, the command "Delete Column" allows 1 column.at once.

    How can I perform this action

    Thanks.



    ------------------------------
    Alex Virrueta
    ------------------------------


  • 2.  RE: Delete Columns

    IBM Champion
    Posted Wed May 15, 2024 01:33 PM

    Hi Alex, 

    You're completely right that the "Delete Column" command in IBM RPA allows for the deletion of only one column at a time. To work around this, you have two main options:

    1. Sequential Deletion
      1. You can run the "Delete Column" command multiple times, once for each column you wish to remove. This method is straightforward but can be time-consuming if you have many columns to delete.
    2. Looping Method
      1. An alternative approach is to use a loop to iterate through a list of columns you want to delete. Below is some pseudo code to get an idea of what I mean

    list_of_columns_to_delete = ["Column1", "Column2", "Column3"]

    // Loop through each column name in the list and delete it from the DataTable
    for column_name in list_of_columns_to_delete:
        deleteColumn --column column_name --dataTable yourDataTable

    For more detailed instructions you can refer to the IBM RPA documentation: https://www.ibm.com/docs/ru/rpa/23.0?topic=table-delete-column



    ------------------------------
    Martin Medina
    ------------------------------



  • 3.  RE: Delete Columns

    Posted Mon May 27, 2024 02:35 AM

    Hi Alex,

    To delete multiple columns from a DataTable in a single operation, you can use the DataTable.Columns.Remove method in a loop, or use LINQ for a more concise approach. Below are examples using C#.

    Using a Loop:

    Here's a method to remove multiple columns by looping through them:



    ------------------------------
    Jude Ighomena
    Senior Manager, Core Network Operations
    Broadbased Communications Limited
    Lagos, Nigeria
    +2348163474613
    ------------------------------