Skip to content

Instantly share code, notes, and snippets.

@Azlirn
Created September 6, 2016 15:01
Show Gist options
  • Save Azlirn/367b966fcac477ce438a0f5cd180738a to your computer and use it in GitHub Desktop.
Save Azlirn/367b966fcac477ce438a0f5cd180738a to your computer and use it in GitHub Desktop.
A simple python script to add text to a line in a text file.
readfile = raw_input("Please Enter The File You Wish To Read: ")
savefile = raw_input("Please Enter The File You Wish To Save: ")
read = open(readfile, "r")
save = open(savefile, "w+")
for line in read:
text = " " # Enter what you would like to append here
text2 = line
newline = text+text2 # You can swap the variables here if you want to add something to the beginning or end of the line.
if newline not in save:
save.write(newline)
print line," ==> ",newline
print "\nComplete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment