title: print a different row to the one containing the keyword csv files python 3
body: <p>ok ive given up on trying to get it to read the line after the line that contains the keyword. Two weeks of my life is enough!! Im trying to go around this another way. </p>
  
  <p>Each entry comprises of five rows. Most of my desired text is on the first row, which i am able to access. Previously I was trying to access row[63] on the row following the row containing the keyword "Active". This i can not figure out how to do.</p>
  
  <p>All the five entries contain the same reference number in row[4]. I can assign row[4] from the first line to "pid". I hoped then to be able to use "pid" to check the second line. I.e if a line contains the same "pid" and contains the keyword "Reported by" in row[63] do something. Is it possible to use two if statements within the same code to do this? The code runs but returns a blank text file. Iv tried the second if statement both within and outside the fist if statement. Edit; I can get these statements to write to two different files. I just need them to write to the same file :}</p>
  
  <p>import csv</p>
  
  <pre><code>with open("test.csv", "r") as f, open("cops.txt", "w") as output:
      r = csv.reader(f)
      for row in r:
          if "Active" in row and row[0] and row[32]: 
              pid = row[4]
              num = row[13]          #this part is working
  
          #im trying to get this to check the lines after the line with "Active" in it
  
          if pid == row[4] and "Reported by" in row and row[63]: #is it possible to use variable pid from the 1st if statement in this if statement?
              rpt_by = row[63]
              name = row[64]
              output.write(f"PID: {pid} - " + "{} - {}".format(row[6], row[1])
              + "  {}\n \n \n".format(row[19]) + "{} \n \n".format(row[32]) + f"Investigating Member: {num}" +"\n\n\n\n\n") #this part is working
              + (f"{rpt_by} + {name}") #I want to append this to my current code
  </code></pre>