title: Better regex implementation than for looping whole file?
body: <p>I have files looking like this:</p>
  
  <pre><code>#     BJD     K2SC-Flux EAPFlux   Err  Flag Spline
  2457217.463564 5848.004 5846.670 6.764 0 0.998291
  2457217.483996 6195.018 6193.685 6.781 1 0.998291
  2457217.504428 6396.612 6395.278 6.790 0 0.998292
  2457217.524861 6220.890 6219.556 6.782 0 0.998292
  2457217.545293 5891.856 5890.523 6.766 1 0.998292
  2457217.565725 5581.000 5579.667 6.749 1 0.998292
  2457217.586158 5230.566 5229.232 6.733 1 0.998292
  2457217.606590 4901.128 4899.795 6.718 0 0.998293
  2457217.627023 4604.127 4602.793 6.700 0 0.998293
  </code></pre>
  
  <p>I need to <strong>find and count</strong> the lines <strong>with Flag = 1</strong>. (5th column.) This is how I have done it:</p>
  
  <pre><code>foundlines=[]
  c=0
  import re
  with open('examplefile') as f:
      for index, line in enumerate(f):
          try:
              found = re.findall(r' 1 ', line)[0]
              foundlines.append(index)
              print(line)
              c+=1
          except:
              pass
  print(c)
  </code></pre>
  
  <p>In Shell, I would just do <code>grep " 1 " examplefile | wc -l</code>, which is much shorter than the Python script above. The python script works, but I am interested in whether <strong>is there a shorter, more compact way to do the task than the script above</strong>? I prefer the shortness of Shell so I would like to have something similar in Python.</p>