I have written a script to remove excess spaces from a foreign language text. When I execute the script in Windows command prompt, I receive no errors. Everything looks perfect. However, the output file which I specified in my script is not created nor the input file modified. I tried creating a blank document 'corpus_1' for the script to write to. Then I tried just writing back to the input file. Either way, the specified file remains unmodified. How do I get my script to write to a file? What am I missing in my code?
def lettersWhitespace():
replacements = {' ':' ', 'c ':'c'}
with open('C:\\Users\\Charles\\corpus.odt','w+') as infile, open('C:\\Users\\Charles\\corpus_1.odt', 'w') as outfile:
for line in infile:
for src, target in replacements.iteritems():
line = line.replace(src, target)
outfile.write(line)
EDIT: I believe that I have found the problem. It appears that my first line, 'def lettersWhitespace():' is redundant. As written, the script is defining a function, but not calling that function. Does this sound correct?