Post
Topic
Board Development & Technical Discussion
Re: python script compare lines in 2 text files and output matches
by
crofrihosl
on 24/09/2019, 17:30:52 UTC
Does it have to be python? Bash command comm does exactly what you need:
Code:
comm -12 <(sort file1) <(sort file2)

I don't know how fast a Python loop would be, but the above code takes about 0.05 seconds for 2 files with 50,000 lines each.

i use windows so yes it has to be python
yes it is very very slow for files above 1,000,000 lines

when i want to compare a files with +10,000,000 lines to other 2,000,000 lines (i had to cancel and close the script Undecided )

i sort the first file then i split it to many small files 100k lines each (and was very very slow too Undecided)   

at some point python did not help my requirement