title: How to process each 'block' of text separately
body: <p>Hoping you can help.</p>
  
  <p>I have a file something like the below. There are lots of lines of text associated with an entry. each entry is separated by ***********</p>
  
  <p>I have written some code that loops through each line, checks some criteria and then writes the output to a csv. However, I don't know how to do that for the whole section, rather than per line.</p>
  
  <p>I kind of want WHILE line &lt;> ***** loop through the lines. But I need to do that for each section in the document.</p>
  
  <p>Would anyone be able to help please?</p>
  
  <p><strong>My attempt:</strong>
  Split lines doesnt seem to work</p>
  
  <pre><code>import csv
  from itertools import islice
  
  output = "Desktop/data.csv"
  f = open("Desktop/mpe.txt", "r")
  
  
  lines = f.readlines().splitlines('*************************************************')
  print(lines)
  for line in lines:
      if 'SEND_HTTP' in line:
          date = line[:10]
          if 'FAILURE' in line:
              status = 'Failure'
          else:
              status = 'Success'
          if 'HTTPMessageResponse' in line:
              response = line
  
  with open(output, "a") as fp:
       wr = csv.writer(fp, dialect='excel')
       wr.writerow([date, status, response])
  </code></pre>
  
  <p><strong>The file:</strong></p>
  
  <pre><code>   line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      *************************************************
  
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      line of text
      *************************************************
  </code></pre>