Skip to content

Instantly share code, notes, and snippets.

@deanlxvii
Created October 14, 2011 12:48
Show Gist options
  • Save deanlxvii/1287015 to your computer and use it in GitHub Desktop.
Save deanlxvii/1287015 to your computer and use it in GitHub Desktop.
Remove multiple spaces from a file
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