I have a list containing several thousand short strings and a .csv file containing several hundred thousand short strings. All list elements are unique. For each string in the .csv file, I need to check to see if it contains more than one list element.
For example. I have a string:
example_string = "mermaids have braids and tails"
And a list:
example_list = ["me", "ve", "az"]
Clearly the example string contains more than one list item; me and ve. My code needs to indicate this. However, if the list was
example_list = ["ai", "az", "nr"]
only one list element is contained.
I think that the following code will check to see if each line in my .csv file contains at least one list element. However, that doesn't tell me if it contains more than one different list element.
data = file("my_file_of_strings.csv", "r").readlines()
for line in data:
if any(item in my_list for i in line):
#Do something#