Created
October 14, 2011 12:48
-
-
Save deanlxvii/1287015 to your computer and use it in GitHub Desktop.
Remove multiple spaces from a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def single_space(fileName): | |
""" | |
remove multiple spaces from a file | |
""" | |
input = open(fileName, 'r') | |
output = open('tmp.txt', 'w') | |
output.write(string.join(input.read().split())) | |
input.close() | |
output.close() | |
os.remove(fileName) | |
os.rename('tmp.txt', fileName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment