How to Compare CSVs having same Keywords

  1. Read both files by using Read CSV activity and put those data into different datatable (set different datatable as output of Read CSV activity, here I name them “dtCSV1” and “dtCSV2”)
    Make sure both datatable’s variable scope is set to “Main”.

  2. Use For Each Row to process all the data in dtCSV1 and use Get Row Item to get “product name” and “price” in CSV1 (here I set the product name to new variable “prodName1” and price to “price1”)

  3. You can filter dtCSV2 with “prodName1” by using DataTable.Select method, like this.
    arrayRowsOfCsv2 = dtCSV2.Select(“product name='” + prodName1 + “'”)
    (This returns array of DataRows and I set it to arrayRowsOfCsv2)
    [see other posts for more detail, there’re lot of posts related to filtering datatable]
    How to use (like ,= operator) with column in Datatable.Select

  4. Now you can get price in the CSV2. I assume there’s only one row that matches filter criteria, then you can get price by
    arrayRowsOfCsv2(0).Item(“Price”)

  5. Finally you can export it to CSV or Excel file. There’re 2 options in my mind. One is to use “Write Cell” for each product, it can be easy. The other is to build new datatable and set retrieved data to it, and then use Write CSV or Write Range to export the new datatable to a file.

I maybe have time to create sample flow later but anyway I just post this since you’re really in haste.

2 Likes