Situation: Comparing strings in fileA with pre-defined strings in fileB. Example of said function in my code:
string = open('fileA', 'r')
stringlist = open('fileB', 'r')
//compare the strings
for i in string:
for j in stringlist:
if i == j:
print("Same String found!" + i + " " + j)
Problem: In my actual program, string contains more than 200 strings, while stringlist is a file with more than 50,000 strings. The nested for loop, as I have read, is slow as a comparison function.
Question: What is the fastest way to compare the two files' content?
Additional information 1: Both files are CSV files, and are opened in my program as CSV-delimited.
Additional information 2: Strings are md5 hashes (32 characters).
Additional information 3: I am open to other ways to store the strings, i.e. Compare the strings on-the-fly instead of saving it to fileA.
Additional information 4: I am also open to other methods or modules that I can use (i.e.: Threading/parallel processing) -- speed is the key here.