Compare 2 lists

sorry man i just didnt want to make lot of topics, thank you for the help.

can we use this to compare 2 lists and only get the difference between this 2?
for example:
textfile1:
1,2,3
text file2:
1

the results should only contains β€œ1”

I don’t understand, if one has 1,2,3 and the other has 1 then the difference wouldn’t be 2,3?

lets say text file 1
contains lines like this
1
2
3
and text file 2 contains lines
2
3

so the results should be 1 because its not found on both lists. is it possible to do that ?

Read the 2 files to 2 lists using the read all lines block (once per file) and then you can do something like this

var firstFile = new List<string> { "1", "2", "3" };
var secondFile = new List<string> { "2", "3" };
var different = firstFile.Where(i => !secondFile.Contains(i)).ToList();
1 Like

COPY PASTE THIS IN LOLISCRIPT

MAY THIS HELP YOU ; USING IRONPYTHON

BLOCK:ConstantList
value = [β€œ1”, β€œ2”, β€œ3”]
=> VAR @L1
ENDBLOCK

BLOCK:ConstantList
value = [β€œ2”, β€œ3”]
=> VAR @L2
ENDBLOCK

BLOCK:Script
INTERPRETER:IronPython
INPUT L1,L2
BEGIN SCRIPT
L=[]
for i in L1:
if (i in L2):
print(β€œsed”)
else:
L.append(i)
END SCRIPT
OUTPUT ListOfStrings @L
ENDBLOCK

1 Like

IS THIS WHAT U WANTED ?

if you want to use ironpython
think about the built-in function in SET
so you will convert the list to set like set(list())

https://www.w3schools.com/python/python_ref_set.asp

this one already do the loop of the lists in a smart way and very fast
good luck

1 Like

yes something like this should work im going to work on few things and try your script.

sure TRY AND TELL DOES IT DOES HELP
btw the one told by @qMp u should try it

i have an issue when i added your ironpython script and i tried to remove it so i can do something but wont let me i keep getting this error msg

i restarted ob but nothing i keep getting same message.

Post the lolicode please

this is not full script i just dont want to put sites in the forum but its only request blocks . the problem i just wanted to put the script and see how it will look like when i tried to remove it i cant get that done

BLOCK:Parse
LABEL:LINKS
input = @data.SOURCE
pattern = β€œ(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png|jpeg|mp4|m4v)”
outputFormat = β€œ[0]”
RECURSIVE
MODE:Regex
=> VAR @Links
ENDBLOCK

BLOCK:ConstantString
LABEL:SER VARIABLE
value = @Links
=> VAR @LIST
ENDBLOCK

BLOCK:Replace
original = @LIST
toReplace = β€œ[”
=> VAR @LIST
ENDBLOCK

BLOCK:Replace
original = @LIST
toReplace = β€œ]”
=> VAR @LIST
ENDBLOCK

BLOCK:Split
input = @LIST
separator = ", "
=> VAR @NEWLIST
ENDBLOCK

BLOCK:RemoveDuplicates
list = @NEWLIST
=> VAR @DUPS
ENDBLOCK

BLOCK:ConstantList
value = @DUPS
=> VAR @L1
ENDBLOCK

BLOCK:ConstantList
value = @DUPS
=> VAR @L2
ENDBLOCK

BLOCK:Script
INTERPRETER:IronPython
INPUT L1,L2
BEGIN SCRIPT
L=
for i in L1:
if (i in L2):
print(β€œsed”)
else:
L.append(i)
END SCRIPT
OUTPUT ListOfStrings @L
ENDBLOCK

fixed by removing the script and adding new block