Advertisement
rooseal

List Overlap

Oct 11th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import os
  2.  
  3. my_set = set(line.strip() for line in open('testinputlist.txt'))
  4.  
  5. def flatten(iterable):
  6.    out = []
  7.    for i in iterable:
  8.       if hasattr(i,'__iter__'):
  9.          out.extend(flatten(i))
  10.       else:
  11.          out.append(i)
  12.    return out
  13.  
  14. path = "."
  15. listing = os.listdir(path)
  16. for filename in listing:
  17.     with open(filename, 'r+') as f:
  18.         search_set = set(line.strip() for line in f)
  19.         tabset = [i.split('\t') for i in search_set]
  20.         final = flatten(tabset)
  21.         if set(my_set).isdisjoint(final) == False:
  22.             print filename + " is a match!"
  23.         else:
  24.             print filename + " is not a match"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement