title: How to process information from multiple lines in python?
body: <p>I have a tab-delimited file that looks something like this:</p>
  
  <pre><code>\&gt;WB02      \t F27C8.1  
  IV  \t      B-9641      
  \&gt;WB03  \t  F07C3.7   
  \&gt;WB04  \t  F52H2.2   
  \&gt;WB04  \t  F52H2.2   
  \&gt;WB05  \t  T13A10.10     
  IV  \t  B-15643   
  IV  \t  B-11650   
  IV  \t  B-13649
  </code></pre>
  
  <p>Using python, I would like to pair information from the lines that start with a '>' to information from any lines that follow that so not start with a '>.' Every time there is a '>' line followed by a non '>'line, I would like to print the column 2 value from the '>' line, followed by a tab, followed by the column 2 value from the non '>' line. For example:</p>
  
  <pre><code>F27C8.1 \t B-9641  
  T13A10.10 \t B-15643  
  T13A10.10 \t B-11650  
  T13A10.10 \t B-13649  
  </code></pre>
  
  <p>To now, I have written scrips that read files line-by-line. In this case, will I need to read the whole file into memory? The input file won't exceed about 30K lines, at about 10MB total. After that, I assume I will start with something like "For each line that does not start with a '>' get the value from column 2 of the nearest preceeding line that starts with a '>.' I'd appreciate any pointers in the right direction for reading - this is a bit more complicated than anything I have done so far (baby steps!).</p>