CSV Automation. Find Similarities and Differences Between Two CSV Files
To be able to run this example you need to install UiPath.Excel.Activities. See more details on how to install packages
This sample read two csv files and write a csv file with similarities and another one with differences.
Steps to automate
- Read both CSV files.
- Build two data tables for similarities and for differences.
- Find related items from both CSV and put them in a data table for similarities.
- Find the different elements from both CSV and put them in a data table for differences.
- Write both CSV files with similarities and differences.
- Read both CSV files using "Read CSV" activity.
- Build two data tables for similarities and for differences using "BuildDataTable" activity.
- Go through the first data table that contain csv1 information using a "For Each Row" activity and compare every row from the first CSV with each row from the second CSV.
- If the rows contain the same information, add that row in dtSame.
- Write the result of the previous step in a CSV file using "Write CSV" activity.
- When you try to find the differences uses a "For Each Row" activity and go through dtOld which is the data table that corresponds with first CSV file.
- Then use ".Rows.Find" method to find in dtNew, which is the data table that corresponds with the second CSV file, if you can't find that row then add it to Differences.