To remove some lines from a file

Jerry jweida at gmail.com
Wed Oct 25 09:32:56 EDT 2006


Very inelegant, but you get the idea:

counter = 0

f = open("test.txt")
for line in f.readlines():
    if line[0] != "$" and counter < 2:
        counter += 1
        continue
    else:
        print line,

--
Jerry




More information about the Python-list mailing list