title: Finding the header in a large txt file pandas
body: <p>Suppose I have a large file with a few million lines. The first 300+ (variable number) lines contain info about the file, and then there is a header line before the data. I do not know what line the header is on, but I know what it starts with. Here is a sample of My data:</p>
  
  <pre><code>#This File contains some cool suff
  #We will see what line the header is on
  #Maybe it is in this line
  #CHROM POS ID 
  1 100 17
  2 200 18
  2 300 18
  </code></pre>
  
  <p>The header line is the <code>#CHROM POS ID</code></p>
  
  <p>Here is what I have tried but it returns <code>list index out of range</code>:</p>
  
  <pre><code>database = pd.read_table(infile, header=[num for num,line in enumerate(infile) if line.startswith("#CHROM")])
  </code></pre>
  
  <p>I think I have naively assumed that <code>pd.read_table</code> operates in the same way as <code>with open()</code> and that may have worked. Any help will be appreciated!</p>