i've got a .txt-file that is structured like that:
.
69427 73 69431
.
.
69420 48 69421
.
.
69421 6 69425
.
.
.
69425 28 69427
.
.
the goal is to cut out specific lines, starting with 69420. Then I need to jump to 69421 and cut this line too. The next line will start with 69425 and so on... Each line, starting with a specific number, is only contained one time within the .txt-file. The file isn't sorted by the first number.
I wrote a short python-script, but it isn't working.
file = open("neu.txt", "r")
neue_suche = ""
start = "69420"
def suche(a):
for line in file:
if a in line:
print(line)
next_array = line.split()
neue_suche = next_array[2]
suche(neue_suche)
suche(start)
file.close()
My goal is, to call the function recursively with the new number, after splitting the line and writing this new number in a variable. The new number is the new parameter of the function. The problem is, that the search doesn't start from the beginning of the file. That means, that the line "69427 73 69431" wouldn't be found and printed with this script. The script will end, but I know, that not every line that I need is printed.
Does anyone have an idea what the problem is?
Thanks :)