If your Excel file looks like it was attacked by a copy paste tornado you are in the right place. This short UiPath tutorial walks through reading an Excel sheet into a DataTable removing duplicate rows and writing the cleaned table back to Excel. It is a safe and repeatable approach for RPA automation and data cleaning that does not require black magic.
In plain human terms the flow will
Use Excel Application Scope with a Read Range activity. Store the result in a DataTable variable named dt. If you have headers check the headers option. You can specify the used range or leave the range blank to read the whole sheet. Yes it is that thrilling.
There are two common and reliable options for Remove Duplicates in UiPath depending on whether you prefer code style or activity style.
If you are comfortable with a tiny bit of .NET you can create a distinct table based on one or more key columns. This keeps unique combinations and drops repeat rows that match exactly on your chosen keys. Example assignment
dt = dt.DefaultView.ToTable(true, "Column1", "Column2")
The boolean true tells ToTable to keep only unique rows based on the columns listed. Pick only the key columns that define uniqueness. If you include every column you will effectively keep identical rows only which may or may not be what you want.
UiPath offers a Remove Duplicate Rows activity and a Filter Data Table activity. Use Remove Duplicate Rows when you want a single step that handles duplicates. Use Filter Data Table when you prefer to define include or exclude rules and keep non key columns intact.
Wrap a Write Range inside an Excel Application Scope and write dt to a new sheet or overwrite the old one. Pro tip keep a backup file while testing unless you enjoy irreversible chaos.
If dt.DefaultView.ToTable returns fewer rows than expected check that you passed the correct column names and that whitespace or case differences are not creating false uniqueness. If Filter Data Table removes more than expected inspect your filter rules. For large files the DefaultView ToTable approach is lightweight and fast which is helpful for automation scale in RPA projects.
This approach is easy to slot into larger UiPath automation. Read Range, a choice of duplicate removal, and Write Range form a tidy pipeline for Excel data cleaning. Use the method that fits your comfort level and production needs and enjoy the smug satisfaction of removing duplicates without opening Excel by hand.
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.