Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Compare Data, and Return Data that doesn't Match
Topic Summary:
Created On: 06/01/2012 04:50 AM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by JasonCapo, on Tuesday, June 5, 2012 10:11 AM

Answer:
You my friend are a freakin' genius!

Thank you very much, got it to work!
 06/01/2012 04:50 AM
User is offline View Users Profile Print this message

Author Icon
JasonCapo
Student (5-19 posts)

Posts: 16
Joined: 11/11/2011

Hello,

I'm having a bit of trouble trying to return data that doesn't match from two variables.

I am can however, verify two variables and see if the data matches. But now, I need to know if the data doesn't match, what was the data that wasn't in variable 1 that variable 2 has.

Example:
VARIABLE 1 = Name 1, Name 2, Name 3, Name 4
VARIABLE 2 = Name 1, Name 2, Name 3, Name 4, Name 5

So at all times VARIABLE 1 = should equal VARIABLE 2. However, if it doesn't what file(or in our example what name wasn't in VARIABLE 1).

Can this be done in Automate?

Thanks for any help provided.



 Category Survey
 06/04/2012 02:43 PM
User is offline View Users Profile Print this message

Author Icon
Liz Casale
AUTOMATE EMPLOYEE

Posts: 940
Joined: 05/23/2011

Jason,

Are you able to use the IF statements to compare the variables? If the variables don't match you can put steps in the IF statement like write variable 1 and 2 to a file which you can then look at to see what wasn't in variable 1.

 Category Survey


-------------------------
Liz Casale
Technical Support Representative
(213) 738-6966
Network Automation, Inc.

--------------------------------------------------------------------------------

AM5 5.5.5.1; AM6 6.2.8.0; AM7 7.1.3.0; AM8 8.0.9.0; AM9 9.0.3.4
BPA7 7.1.3.0; BPA8 8.0.9.0; BPA9 9.0.3.4
 06/04/2012 11:15 PM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Jason,
is the non matching part always at the end of variable2 , or anywhere ? Or even in variable 1 ?
The solution will depend on those answers.

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 06/05/2012 04:52 AM
User is offline View Users Profile Print this message

Author Icon
JasonCapo
Student (5-19 posts)

Posts: 16
Joined: 11/11/2011

That's an excellent question Jean.

Come to think of it, yes the non-matching part is always at the end of variable 2.

Perhaps I should give me more background of exactly what I'm doing:

I get a list of files: Say 10 files.

5 (.pdfs or jpgs files (could be mixed matched))
5 (.txt files)

If you open one of the .txt files, it will have the file name of the physical .pdf or .jpg file.

So I'm basically, looping through the directory gathering all the physical files names (excluding .txt files) all listed in VARIABLE 1 - then I'm looping through the .txt files and retriveing the file names from within the .txt file all listed in VARIABLE 2. Then I want to compare those to VARIABLES and display what physical file is missing.

 Category Survey


Edited: 06/05/2012 at 04:59 AM by JasonCapo
 06/05/2012 06:13 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Jason,
the sample below finds in turn the file(s) listed in v2 after those present in v1
Notice it does not check that the common part is really identical in both lists.


 Category Survey
AutoMate 7 version:
Windows version:



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 06/05/2012 10:11 AM
User is offline View Users Profile Print this message

Author Icon
JasonCapo
Student (5-19 posts)

Posts: 16
Joined: 11/11/2011

Answer Answer
You my friend are a freakin' genius!

Thank you very much, got it to work!

 Category Survey
 06/05/2012 10:20 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

You're welcome, Jason.

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/06/2014 01:51 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi,

i would like to use this script but i see that the list needs to be formatted as follow:

number,

number,

ending number (without ,)

is there any way it can be adjusted without the use of comma?

Regards



 Category Survey
 01/06/2014 12:04 PM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Fabio,
if instead of commas the numbers are separated by a (single) space, you could replace in the task all the "," with " "
But if there are a variable number of spaces, you should first replace all series of spaces by a single space.

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/07/2014 12:49 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi,

i did replace the comma with spaces but the variable "i" will give only the ammount of files missing(ex 2) instead the filename of the file missing(ex name1,name2).

i'm looking for a solution to filter out :

var 1 - var 2= i (difference between the two with file names results)

my 2 variables will be filled up in a column with only the file name:

v1=

711234

437272

237727

v2=

711234

437272

i=

237727

how can i make it work?

thansk for the help.

 



 Category Survey
 01/07/2014 01:01 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Fabio,
not seeing your task does not help me giving you advice.
Could you post your task steps ? And elaborate a bit more on what you intend doing with it ?

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/07/2014 05:09 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi,

sorry if i didn't add too many details.

here is what i'm trying to do...

As you can see from the attached code we have a list of files that we need to publish in my "list.txt" (v2) but some of them might not be avaialble. By looping the output folder where the files should be ,i will create a variable containg the files that have been processed.

My target is to create a 3rd variable(i) containing the list of the file names not available from v2(ex this_Video,That_Audio,This_text) by subtracting :

v2-v1=i 

Your line of code seems working only if each file listed in the variables have a comma after the file name(ex 1234,5678,91011) excluding t the last entry.

If i add a comma to all the entries in the variables or i leave space , i will have returned only the quantity of missing files but not the file names.

is there a way i can mod your script to make it work for me?

Many thanks for the help

 



 Category Survey



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)
 01/07/2014 11:55 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Fabio,
I am unsure I understand.
But
If v1 has the full list e.g.: abc,def,ghi,jkl,mno
and v2 only some of them e.g.: def,jkl,mno
there is a possibility to create a v3 containing the missing ones: abc,ghi
as follows
create v3 by adding a leading and a trailing comma to v1 : ,abc,def,ghi,jkl,mno,
Then loop the v2 list (resultvariable vx e.g. def)
- add a leading and a trailing comma to vx (e.g. ,def,)
- in v3 replace %vx% with a single comma (this removes from v3 the files present in v2 specified in vx)
end of loop
now v3 contains the missing files with a leading and a trailing comma e.g. ,abc,ghi,
remove from v3 the leading and the trailing commas
now v3 contains only the list of the missing files. abc,ghi

Does this make sense ?

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/09/2014 06:34 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi Jean,

you understood right! my problem (like Jason) is that i have difficulties in extracting the missing files from the 2 variables  in a consistent way.

it's all clear now except i don't know how to add a leading and trailing comma as you mentioned before:

"create v3 by adding a leading and a trailing comma to v1 : ,abc,def,ghi,jkl,mno,"

my v1 variable is looking like this:

test1

test2

test3

how i change it in?

test1,

test2,

test3

consider i won't know how many entries i will have in the next list and how long it will be the file name of the new files. It could have a random ammount of items and a random lenght of the name.

The only recursive element of this variable is that the list will appear always in a column.

What would you do ?

Regards



 Category Survey
 01/13/2014 05:25 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi,

i think my problem is that my list doesn't come with a separation between the content: a,b,c,d

but it comes in a column that has only a "return" as separation:

a

b

c

if i add comma at the beginning and at the end i will have:

,a

b

c,

which is not what i need.

Anyone with a brilliant idea?

Regards



 Category Survey
 01/13/2014 06:11 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Have a look at this, Fabio

 Category Survey
AutoMate 7 version:
Windows version:



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/15/2014 01:12 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi Jean,

this last code works! i can now create a list separated by comma but unfortunately i'm still stuck in creating a reliable return information of what is missing between the two variables.

i just realized that the code you suggested before (File in v2 missing in v1 : %Trim(Split(v2,",")(i-1)) isn't working for me.

for some reasons is not giving a reliable return. Maybe the list needs to be from small to high numbers sequence? Could you explain how this expression works?          %Trim(Split(v2,",")(i-1)

Regards



 Category Survey


Edited: 01/15/2014 at 01:36 AM by FabioGrammatico
 01/15/2014 03:04 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Fabio, here we go

%Trim(Split(v2,",")(i-1))%
BTW Beware of all the ( ) and %

There is no need for sorting the sequence.

v2 is a string that contains something like xcv,tyu,klm
Split(v2,",") is an array with three elements : (0) xcv (1) tyu (2) klm
Split(v2,",")(i-1) is the ith element of the array
if i=2 Split(v2,",")(1) is tyu (2nd element of the array)
Trim() removes any possible leading or trailing spaces (this is optional, just in case there are any extra spaces)

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/15/2014 03:50 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi,

for me it only works if the 2 variables have the same list order but won't work

if the order is shuffled.

i have attached the code with the list in V1 in different order respect V2.

is there anything we can do to make it work?

thank you so much for the explanation.

Regards

 



 Category Survey



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)
 02/13/2014 12:33 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi,

could someone try the code above to confirm the results are wrong?

many thanks!



 Category Survey
 02/13/2014 04:29 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

Fabio,
could you have a look at this ?

 Category Survey
AutoMate 7 version:
Windows version:



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 02/20/2014 12:06 AM
User is offline View Users Profile Print this message

Author Icon
FabioGrammatico
Journeyman (50-99)

Posts: 57
Joined: 05/02/2013

Hi Jean,

I don't know exactly what you've changed but this works perfectly! i'll try to decypher it and learn as much as i can from it.

Many thanks for the teaching!

 



 Category Survey


Edited: 02/20/2014 at 07:36 AM by FabioGrammatico
 02/20/2014 08:11 AM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

You're welcome, Fabio.
Basically, I just loop v1 to get each item in turn, and remove that item from v3.
What is left in v3 at the end is those items that were not present in v1

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/27/2016 12:00 AM
User is offline View Users Profile Print this message

Author Icon
HaHa
Apprentice (20-49)

Posts: 26
Joined: 08/02/2015

hello

i'm not sure if this solution suits me completly, what i want is to compare the file names in two different folders ignoring the file's extensions and what is different in folder 2 will be deleted.

any support on that?



 Category Survey
AutoMate 7 version:
Windows version:
 01/27/2016 09:53 AM
User is offline View Users Profile Print this message

Author Icon
Alex Escalante
HelpSystems

Posts: 871
Joined: 02/26/2014

Hello,

Yes, you would need to loop through both folders creating a dataset for each folder. Loop through the dataset to trim the extensions and just leave file names. You can then use "if statements" to compare each file to each other deleting the files where there is no match.

 Category Survey
AutoMate 7 version:
Windows version:


-------------------------

Alex Escalante | Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1480 guests browsing this forum, which makes a total of 1480 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog