I have an input file that looks something like this:
#nP 4
#mP 0.0262
#mH 10
#HP various info:
14 H 0.026
19 P 0.054
20 H 0.012
512 H 0.005
#xP
#kP
99
89
90
I want to extract 4 lines (because np = 4 in the first line) starting from line 5, so the output would be like this:
14 H 0.026
19 P 0.054
20 H 0.012
512 H 0.005
I have tried this:
import sys
head = sys.stdin.readline()
head = head.strip()
head = head.split('\t')
cntHetPos = int(head[1])
if "#HP" in sys.stdin.readlines():
lines = sys.stdin.readlines()[0:cntHetPos]
print lines
but it doesnt print out the lines, nor gives an error message. I based this on a previous answer I found here: Read file from line 2 or skip header row Ideas?