Created
January 31, 2024 20:02
-
-
Save se7enack/4c2778b2a1b7397ae3e3bd62b5f057e5 to your computer and use it in GitHub Desktop.
Delete all lines before a line that starts with a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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