Advertisement
Guest User

blankrem.py

a guest
Dec 27th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. # to run: python <this file> <files to remove blanks from>
  2.  
  3. from sys import argv
  4. from os.path import isfile
  5. for arg in argv:
  6. if isfile(arg):
  7. with open(arg,"r") as _in:
  8. text = _in.read()
  9. while "\n\n" in text:
  10. text = text.replace("\n\n","\n")
  11. extstart = arg.rfind('.')
  12. newname = arg[:extstart]+"_noblanks"+arg[extstart:]
  13. with open(newname,"w") as out:
  14. out.write(text)
  15. else:
  16. print "no such file "+arg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement