Advertisement
skip420

addQuotes

Jun 20th, 2022
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import os
  2.  
  3. with open("file1.txt") as i: # open file for reading, i = input file
  4.   with open("temp", "w") as o: # open temp file in write mode, o = output
  5.      for l in i: # read line by line  
  6.          o.write("'%s', \n" % l[:-1]) # concate ' and text
  7.           #       ^  ^ added `'` for each line  
  8. #os.remove("file2.txt") # delete old file. Note:this is not needed in postfix system
  9. os.rename("temp", "filetest2.txt")  # rename file
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement