How to compare a different text file and its data inside of it, after the extraction?

How to compare a different text file and its data inside of it, after the extraction?

what you’re comparing Can you provide a specific scenario?

@NervousTuber

Here’s the scenario:

  1. Check the filename on both file if they are the same name? Note: No need to print it out just TRUE OR FALSE.

  2. Check all the possible data inside the file LINE-BY-LINE? Note: if there’s some file with data that does not match to other file with data, use Append Line Activity to store the data comparison.

     [Example Output Results]
         filter_message.cfg
           before_change(line:1) : #test1
           after_change  : 
    
         filter_time.cfg
           before_change(line:6) : #test2
           after_change (line:6) : #test3
    

And here’s the file that I need to compare:
BeforeExample.zip (1.2 KB)
AfterExample.zip (1.3 KB)

Hey @NervousTuber

Did you already see my message?

Regards,
France

Give me 30 minutes and I will provide you with a solution.

Thanks,
Vinit

1 Like

Hey @NervousTuber

Okay thank you so much.

Thanks,
France

Hey @fniedez ,

I created one sample workflow based on your requirements Please check and mark this post as a solution if you found the answer you were looking for.

TextCOmpare.zip (5.5 KB)

Thanks,
Vinit Mhatre

1 Like

To compare a different text file and its data inside of it after the extraction in UiPath, you can use the Read Text File activity to read the contents of both text files into string variables, and then use the Compare activity to compare the contents of the two variables.

Here are the steps to do this:

  1. Use the Read Text File activity to read the contents of the first text file into a string variable. Specify the path to the text file in the Read Text File activity’s FilePath property.
  2. Use the Read Text File activity to read the contents of the second text file into another string variable.
  3. Use the Compare activity to compare the contents of the two string variables. Set the Expected property to the first string variable and the Actual property to the second string variable.
  4. Use an If activity to check the result of the comparison. If the Compare activity returns True, the contents of the two text files are the same. If the Compare activity returns False, the contents of the two text files are different.

Here is an example of how this could be implemented in UiPath:

ReadTextFile file1 = new ReadTextFile();
file1.FilePath = “C:\file1.txt”;

ReadTextFile file2 = new ReadTextFile();
file2.FilePath = “C:\file2.txt”;

Compare compare = new Compare();
compare.Expected = file1;
compare.Actual = file2;

If ifActivity = new If();
ifActivity.Condition = compare;

ifActivity.Then = new Sequence();
ifActivity.Then.Add(new WriteLine(“The contents of the two text files are the same.”));

ifActivity.Else = new Sequence();
ifActivity.Else.Add(new WriteLine(“The contents of the two text files are different.”));

file1.Execute();
file2.Execute();
compare.Execute();
ifActivity.Execute();
This code reads the contents of both text files into string variables, compares the contents of the two variables using the Compare activity, and outputs a message depending on the result of the comparison.

1 Like

Hey @NervousTuber

Sorry for late reply, I’ll check you flow there’s no activity that extract two different zip files.

Note: And the results that I need is like this:

 filter_message.cfg
   before_change(line:1) : #test1
   after_change  : 

 filter_time.cfg
   before_change(line:6) : #test2
   after_change (line:6) : #test3

Hey @NervousTuber

I already sent a message to you, kindly check it.

Regards,
France

Hey @sudheern

Can you please do this on the activity or in a flow. Pardon, I didn’t catch your answer.

Regards,
France