![]() |
![]() |
We are currently migrating this forum over to our HelpSystems domain. Please post all new threads in our new HelpSystems Community Portal. |
![]() |
|
![]() |
AutoMate Discussion | ![]() |
help :
faq :
home
|
||
Latest News:
|
latest topics : statistics |
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 |
![]() |
![]()
|
![]() Answer: You my friend are a freakin' genius! Thank you very much, got it to work! | ||||||||||
![]() |
||||||||||
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.
|
||||||||||
|
||||||||||
![]() |
||||||||||
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.
------------------------- 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 |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
Edited: 06/05/2012 at 04:59 AM by JasonCapo |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
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 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
You my friend are a freakin' genius!
Thank you very much, got it to work!
|
||||||||||
|
||||||||||
![]() |
||||||||||
You're welcome, Jason.
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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
|
||||||||||
|
||||||||||
![]() |
||||||||||
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.
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
|
||||||||||
|
||||||||||
![]() |
||||||||||
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 ?
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) |
||||||||||
|
||||||||||
![]() |
||||||||||
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 ?
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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
|
||||||||||
|
||||||||||
![]() |
||||||||||
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
|
||||||||||
|
||||||||||
![]() |
||||||||||
Have a look at this, Fabio
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 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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
Edited: 01/15/2014 at 01:36 AM by FabioGrammatico |
||||||||||
|
||||||||||
![]() |
||||||||||
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)
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) |
||||||||||
|
||||||||||
![]() |
||||||||||
Hi, could someone try the code above to confirm the results are wrong? many thanks!
|
||||||||||
|
||||||||||
![]() |
||||||||||
Fabio,
could you have a look at this ?
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 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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!
Edited: 02/20/2014 at 07:36 AM by FabioGrammatico |
||||||||||
|
||||||||||
![]() |
||||||||||
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
------------------------- Jean Delfosse - Automate Beta Tester Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4 ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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?
|
||||||||||
|
||||||||||
![]() |
||||||||||
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.
------------------------- ![]() Alex Escalante | Support Analyst AutoMate | Division of HelpSystems HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665 |
||||||||||
|
FuseTalk Enterprise Edition v4.0 - © 1999-2021 FuseTalk Inc. All rights reserved.