Reading and writing in python
<p>I'm pretty new at coding and I'm trying to figure out how to solve this question:
Find all the headers that start with # and lines that have the word "PASS" in the 7th column and print them to new.vcf. Pass may show up in other columns but when in the 7th column it will appear alone and in all caps. These files are tab delimited.
I've already completed the first part of the question but can't figure out how to pull "PASS" from the 7th column. Here's the total code I have so far.  </p>

<pre><code>#!/usr/bin/env python
myfile= open("temp.vcf","r")
outfile= open("new.vcf","w")            
for data in myfile: 
    data = data.strip("\t")
    if data[0] == "#":
        outfile.write(data +"\n")
myfile.close()
outfile.close()

myfile=open("temp.vcf","r") 
outfile=open("new.vcf","a")

data=myfile.readline()
while data == "PASS":
    outfile.write(data+"/t")
    data=myfile.readline()  

myfile.close()
outfile.close()
</code></pre>
