Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # to run: python <this file> <files to remove blanks from>
- from sys import argv
- from os.path import isfile
- for arg in argv:
- if isfile(arg):
- with open(arg,"r") as _in:
- text = _in.read()
- while "\n\n" in text:
- text = text.replace("\n\n","\n")
- extstart = arg.rfind('.')
- newname = arg[:extstart]+"_noblanks"+arg[extstart:]
- with open(newname,"w") as out:
- out.write(text)
- else:
- print "no such file "+arg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement