Skip to content

Instantly share code, notes, and snippets.

@MarcoPolo
Created December 11, 2012 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoPolo/4255475 to your computer and use it in GitHub Desktop.
Save MarcoPolo/4255475 to your computer and use it in GitHub Desktop.
matias stuff
infile = open('infile.txt', 'r')
content = infile.readlines() #reads line by line and out puts a list of each line
infile.close() #close the input template file
#here is where you change
content[1] = "foo \n" #replaces content of the 2nd line (index 1)
outfile = open('outfile.txt', 'w') #open up an output file
outfile.writelines(content) #write the content to the file
outfile.close() #close the file (not realllly necessary but good practice)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment