[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding lines in .txt file that contain keywords from two different set()

On 2019-09-08 17:02, A S wrote:
> My problem is seemingly profound but I hope to make it sound as simplified as possible.....Let me unpack the details..:
> 1. I have one folder of Excel (.xlsx) files that serve as a data dictionary.
> -In Cell A1, the data source name is written in between brackets
> -In Cols C:D, it contains the data field names (It could be in either col C or D in my actual Excel sheet. So I had to search both columns
> -*Important: I need to know which data source the field names come from
> 2. I have another folder of Text (.txt) files that I need to parse through to find these keywords.
> These are the folders used for a better reference ( https://drive.google.com/open?id=1_LcceqcDhHnWW3Nrnwf5RkXPcnDfesq ). The files are found in the folder.
> This is the code I have thus far...:
result1 contains a list of strings. None of the words in 'checkhere' are 
in that list. I think what you intended to do was to check whether any 
of those words are in any of the strings of result1:

     for element in checkhere:
         for r in result1:
             if element in r:
                 # Found one, so stop looking for more.