UiPath Remove Data Column Example |Video upload date:  · Duration: PT6M24S  · Language: EN

Learn how to remove a data column from a UiPath DataTable with clear steps alternatives and common pitfalls

If your DataTable has a column that needs to die quietly and without drama then welcome to the party. This short guide shows how to remove columns in UiPath Studio using the Remove Data Column activity or a couple of code friendly alternatives. It is practical RPA advice with a side of sarcasm and zero judgment for messy Excel sheets.

Why remove columns in UiPath

Sometimes source data is clean and pure and full of rainbows. Most of the time it is not. Removing unused or sensitive columns makes your automation faster and safer for downstream steps like filters, joins, and exports to Excel or CSV. Also it reduces the chance of runtime exceptions that make your logs look like a crime scene.

Prepare the DataTable

Create your table with Build Data Table when you want control or use Read Range from Excel for real world data. Give the variable a clear name like dt or dataTable. Confirm the exact column name or index ahead of time so you do not trigger a surprise exception mid workflow.

  • Use Build Data Table or Read Range to get a DataTable variable
  • Name the variable clearly for readability in UiPath Studio
  • Check the column name or index before removal

Use the Remove Data Column activity

This is the visual and safe route. Drop the activity into your sequence or flow and set the DataTable property to your variable. For the Column property use the column name as a string or an index expression if you prefer numbers over feelings.

Example property values that work in UiPath Studio

DataTable: dt
Column: "ColumnName"   ' use the exact name
Column: 2                ' zero based index if you like math

Code and LINQ alternatives

If you crave control or need to do transformations in one line then code expressions are your friend. These work well inside an Assign activity or an Invoke Code when you want less visual clutter and more power.

  • Remove by name with the DataTable API
dt.Columns.Remove("ColumnName")
  • Remove by index
dt.Columns.RemoveAt(2)
  • Keep only specific columns by recreating the table via DefaultView
dt = dt.DefaultView.ToTable(False, "KeepCol1", "KeepCol2")

This last trick is handy when you need to drop many columns and prefer whitelisting over blacklisting.

Safe remove pattern

Prevent runtime drama by checking for column existence before removal. It is tedious but less embarrassing than a logged exception.

If dt.Columns.Contains("ColumnName") Then
    dt.Columns.Remove("ColumnName")
End If

Test and handle errors

Always test removals on a copy of your DataTable while developing. Wrap risky calls in a Try Catch activity to log meaningful error messages. When a column is missing you want to see a nice message not a garbage stack trace that blames your bot for human data chaos.

Quick reference and tips

  • Prefer the Remove Data Column activity for clear RPA design and readability
  • Use code methods for bulk operations or when you need precise control
  • For multiple column changes consider the DefaultView trick to build a new table with only the columns you care about
  • Always check with dt.Columns.Contains("ColumnName") to avoid index out of range surprises
  • Log helpful messages so you can debug later without weeping

There you go. You can now remove DataTable columns in UiPath with less fuss and better error handling. Your workflows will be tidier and your future self will send you a thank you note or at least less passive aggressive logs.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.