Guest User

Untitled

a guest
Feb 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #This program deletes unwanted indenters in a text file.
  2. #To use that program, put the text you want to de-indent into a .txt file.
  3. #Then run the program.
  4.  
  5. filename = input("Enter text file name: ")
  6.  
  7. if filename [-4:] != ".txt":
  8. filename += ".txt"
  9.  
  10. outputfilename = input("Enter output file name: ") + (".txt")
  11. if filename [-4:] != ".txt":
  12. outputfilename += ".txt"
  13.  
  14. chrcount = int(input("Enter how many characters/spaces do you want to delete: "))
  15.  
  16. with open(filename) as textfile:
  17. paragraph = list(textfile)
  18.  
  19. i = 0
  20. for line in paragraph:
  21. paragraph[i] = line[chrcount:]
  22. i+=1
  23.  
  24. paragraph = "".join(paragraph)
  25.  
  26. f = open(outputfilename,'w')
  27. f.write(paragraph)
  28. f.close()
  29.  
  30. print("\n" + outputfilename, "has succesfully created.\n")
  31.  
  32. input("Press enter to continue...")
Add Comment
Please, Sign In to add comment