Resources

Knowledge Base

CSV Automation. Find Similarities and Differences Between Two CSV Files

find0

To be able to run this example you need to install UiPath.Excel.Activities. See more details on how to install packages

here
.

Task

This sample read two csv files and write a csv file with similarities and another one with differences.

Steps to automate

  1. Read both CSV files.
  2. Build two data tables for similarities and for differences.
  3. Find related items from both CSV and put them in a data table for similarities.
  4. Find the different elements from both CSV and put them in a data table for differences.
  5. Write both CSV files with similarities and differences.

Solution

  1. Read both CSV files using "Read CSV" activity.
  2. Build two data tables for similarities and for differences using "BuildDataTable" activity.
  3. 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.
  4. If the rows contain the same information, add that row in dtSame.
  5. Write the result of the previous step in a CSV file using "Write CSV" activity.
  6. 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.
  7. 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.

find_3,14