Hi I have a large file that I want to delete the lines that contain the text ALL and print the file without spaces with just the remaining lines. I started a program
sourcefile = open('C:\\scoresfinal.txt', 'r')
filename2 = open('C:\\nohet.txt', 'w')
offending = ["HET"]
def fixup( filename ):
fin = open( filename )
fout = open( filename2 , "w")
for line in fin.readlines():
if True in [item in line for item in offending]:
continue
fout.write(line)
fin.close()
fout.close()
fixup(sourcefile)
but it doesn't work. any help?
here is my error:
Traceback (most recent call last):
File "C:/Python Make Small File/hetcut2.py", line 18, in <module>
fixup(sourcefile)
File "C:/Python Make Small File/hetcut2.py", line 9, in fixup
fin = open( filename )
TypeError: coercing to Unicode: need string or buffer, file found