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?
Here’s the scenario:
-
Check the filename on both file if they are the same name? Note: No need to print it out just TRUE OR FALSE.
-
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)
Give me 30 minutes and I will provide you with a solution.
Thanks,
Vinit
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
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 File
activity to read the contents of the first text file into a string variable. Specify the path to the text file in theRead Text File
activity’sFilePath
property. - Use the
Read Text File
activity to read the contents of the second text file into another string variable. - Use the
Compare
activity to compare the contents of the two string variables. Set theExpected
property to the first string variable and theActual
property to the second string variable. - Use an
If
activity to check the result of the comparison. If theCompare
activity returnsTrue
, the contents of the two text files are the same. If theCompare
activity 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.
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 @sudheern
Can you please do this on the activity or in a flow. Pardon, I didn’t catch your answer.
Regards,
France