i have an input file that goes something like this:
blah blah
blah blah ;blah blah
blah blah ;blah blah
blah
What my program does is split the lines when it sees a semicolon and goes to the next line which is what i want it to do (i want it to ignore the semicolon bits) producing something like this:
blah blah
blah blah
blah blah
blah
however when it writes to the file it appends the new code to the old, and i just want to have the new code in the file. Is there any way this can be done? Thank You.
f = open ('testLC31.txt', 'r+')
def after_semi(f):
for line in f:
yield line.split(';')[0]
for line in after_semi(f):
f.write('!\n' + line)
f.close()