compare 2 lists?



  • hello is there anyway to compare 2 lists and keep only lines not exist on both list
    for example i have i have list1 contains urls, i know when i do this thing again it will parse again and save those urls that already in list 1.
    example:
    list1 contains:
    1
    2

    list 2 contains :
    1

    i want to know if i can keep only 2 parsed data.



  • @BULMADB Yes it is possible compare two list through while loop and IF statement Example 👇

    #UTILITY_List1 UTILITY File "list1.txt" ReadLines -> VAR "List1" 
    #UTILITY_List2 UTILITY File "list2.txt" ReadLines -> VAR "List2" 
    #UTILITY_Lenth2 UTILITY List "List2" Length -> VAR "Lenth2" 
    SET VAR "INDEX" "0"
    WHILE "<INDEX>" LessThan "<Lenth2>"
    IF "<List2[<INDEX>]>" DoesNotContain "<List1>"
    UTILITY List "List1" Add "<List2[<INDEX>]>" "-1" -> VAR "FinalList" 
    ELSE
    ENDIF
    #FUNCTION_Increment FUNCTION Compute "<INDEX>+1" -> VAR "INDEX" 
    ENDWHILE
    #FUNCTION_Dummy FUNCTION Constant -> VAR "Dummy" 
    

    In this case script will check if data in list2 do not exist on list1 it'll add it to list1, you can adjust it according your needs



  • ty so much. i want only to keep the non found links from list 2 on list one, i know how i will do it , thank you so much , i really appreciate it 🙂


Log in to reply