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:
- Use the
Read Text Fileactivity to read the contents of the first text file into a string variable. Specify the path to the text file in theRead Text Fileactivity’sFilePathproperty. - Use the
Read Text Fileactivity to read the contents of the second text file into another string variable. - Use the
Compareactivity to compare the contents of the two string variables. Set theExpectedproperty to the first string variable and theActualproperty to the second string variable. - Use an
Ifactivity to check the result of the comparison. If theCompareactivity returnsTrue, the contents of the two text files are the same. If theCompareactivity returnsFalse, 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.