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

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