UiPath Activities

The UiPath Activities Guide

Remove Data Row/Column

The example below explains how to remove rows and columns from a DataTable by using the Remove Data Column, Remove Data Row, For Each Row, and Get Row Item activities. You can find these activities in the UiPath.System.Activities package.

This is how the automation process can be built:

  1. Open Studio and create a new Process.
  2. Drag a Sequence container in the Workflow Designer.
    • Create the following variables:
Variable Name
Variable Type
Default Value

DT1

DataTable

-

RemovedRows

List<DataRow>

new List(of DataRow)

StringDT

String

-

Note:

Add your .xlsx files to the project directory in order to be able to run the entire process from the same place.

  1. Drag a Read CSV activity inside the Sequence container.
    • In the Properties panel, add the expression "challenge.csv" in the FilePath field.
    • Select the Comma option from the Delimiter drop-down list.
    • Select the check box for the IncludeColumnNames option.
    • Add the variable DT1 in the DataTable field.
  2. Place a Remove Data Column activity below the Read CSV activity.
    • In the Properties panel, add the expression "Phone Number" in the ColumnName field.
    • Add the variable DT1 in the DataTable field.
  3. Drag a For Each Row activity below the Remove Data Column activity.
    • Add the variable DT1 in the DataTable field.
  4. Select the Body container of the For Each Row activity and create the following variables:
Variable Name
Variable Type
Default Value

Address

GenericValue

-

AddressNumber

Int32

-

  1. Place a Get Row Item activity inside the Body container.
    • In the Properties panel, add the expression "Address" in the ColumnName field.
    • Add the value row in the Row field.
    • Add the variable Address in the Value field.
  2. Drag an Assign activity underneath the Get Row Item activity.
    • Add the variable AddressNumber in the To field.
    • Add the expression CInt(Address.Split(" "c)(0)) in the Value field.
  3. Add an If activity below the Assign activity.
    • Add the expression AddressNumber >= 10 And AddressNumber <= 50 in the Condition field.
  4. Drag an Add to Collection activity in the Then field.
    • In the Properties panel, add the variable RemovedRows in the Collection field.
    • Add the value row in the Item field.
    • Select the System.Data.DataRow option from the TypeArgument drop-down list.
  5. Drag a For Each activity below the For Each Row activity.
    • In the Properties panel, select the System.Data.DataRow option from the TypeArgument drop-down list.
    • Add the variable RemovedRows in the Values field.
  6. Place a Remove Data Row activity inside the Body of the For Each activity.
    • In the Properties panel, add the variable DT1 in the DataTable field.
    • Add the value row in the Row field.
  7. Drag an Output Data Table activity below the For Each activity.
    • In the Properties panel, add the variable DT1 in the DataTable field.
    • Add the variable StringDT in the Text field.
  8. Add a Write Line activity under the Output Data Table activity.
    • Add the variable StringDT in the Text field.
  9. Run the process. The robot removes the specified fields from the provided table and prints the new DataTable in the Output panel.
  10. This is how your workflow should look:

Updated 4 months ago


Remove Data Row/Column


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.