Need help in comparing data xlsx and csv files

Hi friends,
Need a help to optimise time of comparsion.

I need to compare csv and xls file, i’ve used for each row activity in another for each activity and if block:
if “rowname” from xls file = “rowname” from csv file
and sum (“rowname” from xls file + “rowname” from csv file) <> 0.
Result of this condition is a new xls file.
Its working to long, about 2 mins.
I dont understand how to read files to arrays for further comparsion, i think in arrays it will be much faster.
I`m newby in UiPath, sorry for dum question.

Compare_V.3.xaml (22.8 KB)

1 Like

Please load CSV and Excel file into DataTables and compare two datatables.

ReadCSV activity for reading CSV file
Excel Application Scope → ReadRange activity for reading excel file

Karthik Byggari

Thanks KarthikByggari,

i’ve tried to load xls to data table using for each activity, but it still to long.
Maybe i dont understand how to load data to data table.
Can you please add xaml file where you load xls or csv to data table?


Not using for each activity.
You can load all the data into a datatable at once using Excel Read Range Activity.

For Excel and Data tables automation please watch the following video -

For loading CSV, directly use Read CSV activity.

Karthik Byggari

Thanks, but I’ve already saw that tutorial.
My xaml already working, but too long.
I’ve reading two files into dt, than comparing two data tables using for each row activity in another for each. I need next result:
If account in file 1 = account in file 2 and sum in file 1 + sum in file 2 <> 0, output all matching results to xls file.

Best regards,

Here you can avoid looping thru each row using FOR loop.
Instead of that you can use LINQ query.

Karthik Byggari

Thanks for your help, but i dont get how to do that.
Can you please give an example how to compare data in 2 files,
condition is:
if account1 = account 2 and (out1+out2)<>0
add data row. (6.3 KB)