Skip to content

Instantly share code, notes, and snippets.

@se7enack
Created January 31, 2024 20:02
Show Gist options
  • Save se7enack/4c2778b2a1b7397ae3e3bd62b5f057e5 to your computer and use it in GitHub Desktop.
Save se7enack/4c2778b2a1b7397ae3e3bd62b5f057e5 to your computer and use it in GitHub Desktop.
Delete all lines before a line that starts with a string
found = 0
mystring = "Code"
with open("inputfile.txt", "r") as input:
with open("outputfile.txt", "w") as output:
for line in input:
if line.startswith(mystring):
found = 1
if found == 0:
pass
else:
output.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment