Skip to content

Instantly share code, notes, and snippets.

@pingswept
Created August 8, 2017 14:54
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 pingswept/85cbb6dc905fb34cce68a449061d2e37 to your computer and use it in GitHub Desktop.
Save pingswept/85cbb6dc905fb34cce68a449061d2e37 to your computer and use it in GitHub Desktop.
Script for Chris to manipulate his G-code
infile = "infile.txt" # the file to open
copies = 3 # how many copies to make
marker = "STARTHERE\n"
with open(infile, 'r') as infile:
lines = infile.readlines()
#print(lines)
startline = lines.index(marker)
result = ''.join(lines + (lines[startline + 1:] * copies))
with open('output.txt', 'w') as outfile:
outfile.write(result)
#print result
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment