title: Finding all specific strings in a file, and get the highest value out of the line
body: <p>Ok, so I couldn't find an appropriate title so Ill explain as best I can.</p>
  
  <p>I have a list made from the data of another file that is made out of names, lets take for example something like this one <code>list = ['AAA','BBBB','CCCC','DDDD']</code>. I want to search in another file all the elements of that list, and all the lines that contain them. Lets say my txt file looks like this.</p>
  
  <pre><code>    PIN |Direction |MaxUp     |MaxDn     |MinUp     |MinDn     |Net                                                                             
     AAA  |  IN      |0.46      |0.039     | -0.006   |0.009     | Top/AAA
     AAA  |  IN      |-0.015    |-0.020    |  0.016   |0.030     | Top1/AAA
     AAA  |  IN      |0.029     |0.019     | -0.006   |0.009     | Top2/AAA
     AAA  |  IN      |0.036     |0.029     | -0.006   |0.009     | Top3/AAA 
  </code></pre>
  
  <p>So My code looks as follows:</p>
  
  <pre><code>for string in list:
      with open('Text.txt') as file:
           for lines in file:
                if string in lines:
                    #Get all lines
                    #Get the line with the highest maxup and Maxdn
  </code></pre>
  
  <p>The output of the process should show all the lines that have the string we are currently looking at so:</p>
  
  <p>it should show all the 4 lines that hold AAA in this case, and it will then only get the with the highest MaxUp and MaxDn so output should be:</p>
  
  <pre><code>    PIN |Direction |MaxUp     |MaxDn                                                                               
     AAA  |  IN      |0.46      |0.039
  </code></pre>
  
  <p>I have a general Idea of what I should be doing but the process takes a long time since Im opening a file in a for loop seems kinda wrong to me.</p>