I am trying to use a code by someone else, but it keeps failing at one specific point. The code needs to find a multiline string in some inputfile and split the inputfile in two. The code seems logical to me, but I keep getting the same error. The inputfile looks something like this:
Text
more text 1
more text 2
VECTT
0 0 0 0 0
more text 3
more text 4
more text 5
Here is a minimal working example:
vfile = open('inputfile','r').read()
vesta_end = vfile.split("VECTT\n 0 0 0 0 0")[1]
print(vesta_end)
I would expect to get the second part of the inputfile, so:
more text 3
more text 4
more text 5
Instead, I get following error:
Traceback (most recent call last):
File "min.py", line 2, in <module>
vesta_end = vfile.split("VECTT\n 0 0 0 0 0")[1]
IndexError: list index out of range
which, I believe, just means it did not recognize the intended string passed to the split function. Any ideas on how to make the function recognize the multiline string?