UiPath Read, Write and Filter CSV Files Example |Video upload date:  · Duration: PT5M40S  · Language: EN

Learn how to read write and filter CSV files in UiPath with clear steps and simple examples for reliable RPA data handling

If your automation needs to chew through CSVs without staging a melodrama, this guide shows how to do it in UiPath Studio like a competent robot. We will read a CSV into a DataTable, filter or mutate rows, then write the result back to a new file. You get clean output, better error handling, and fewer support tickets at 2 a m.

Quick overview of the workflow

High level first so you feel smart before the details hit. The flow looks like this

  • Read CSV into a DataTable using the Read CSV activity
  • Filter or transform rows using DataTable methods or a For Each row loop
  • Validate and handle edge cases to avoid runtime surprises
  • Write the cleaned DataTable back to disk with Write CSV

Read the CSV into a DataTable

Drag the Read CSV activity into your sequence. Point FilePath to the source file and save the output to a DataTable variable such as table or dtInput. If your file uses tabs or pipes instead of commas, set the delimiter accordingly. If you want culture aware parsing, set the appropriate culture so numbers and dates do not fight you.

Tips for robust parsing

  • Trim whitespace early to avoid phantom mismatches with row("ColumnName").ToString.Trim()
  • Specify the delimiter explicitly when the source system is unpredictable
  • If headers might be missing, detect that and either add default headers or fail with a useful log message

Filter or transform the DataTable

Want rows where Age is over 30 Use the Select method to pick them

Dim selected = table.Select("Age > 30")
Dim filtered = If(selected.Any, selected.CopyToDataTable(), table.Clone())

Yes you must validate before CopyToDataTable because it throws if the selection is empty. A safe pattern is to check selected.Any or verify selected.Length > 0 first. For column edits loop with For Each row in table and assign values like

For Each row As DataRow In table.Rows
  row("Status") = SomeNewValue
Next

When to use Select versus LINQ

Use DataTable.Select for quick filters, and LINQ to DataSet when you need more complex transformations. Both keep you in-memory and fast enough for typical RPA CSV handling scenarios.

Write the result back to a CSV

Use the Write CSV activity. Set the Input to your DataTable variable and the FilePath to the output location. Decide whether to overwrite or archive previous files. Archiving is the polite choice when you want to explain mistakes to auditors later.

Validation and error handling

Protect your workflow with a few proven checks

  • Check table IsNot Nothing and table.Rows.Count > 0 before calling CopyToDataTable
  • Wrap file operations in Try Catch to catch IO exceptions for locked files or missing permissions
  • Log clear messages so you can blame the source system instead of your automation

Putting it together

So the practical pipeline in UiPath Studio looks like this. Read CSV into a DataTable, optionally filter or modify rows with Select or a For Each loop, validate the result, then Write CSV. Add Try Catch blocks around file IO, trim values early, and set a culture aware delimiter if needed. That gives you reliable CSV handling for RPA automation without drama.

Final sanity checks

  • Do a dry run with a small sample file
  • Confirm header names and data types match expectations
  • Decide on an overwrite policy so your logs do not look like a crime scene

If you follow these steps you will have a maintainable UiPath workflow that reads writes and filters CSV files, and you will have earned at least some respect from ops. Now go automate something.

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.