What I am trying to do is read a line from one file to a string, then search another file for the line that contains that string and parse that line with .split()
.
My code looks like this:
for line in portslist:
marker = line.split()
printername = marker[0]
address = marker[1]
for lines in constantfile:
if address in line: #if the desired address is in the line
lineholder = line
lineholder = lineholder.split()
oldonline = lineholder[4]
oldutc = lineholder[5]
status = lineholder[2]
However, I get the error
in readermain oldonline=lineholder[4] IndexError: list index out of range
After some trouble shooting it appears that the line from my constantfile is never being assigned to line. Instead it seems the line from the file portlist is being assigned to line, which only has an index of two.
My question is how to make the line that the string "address"
is in assigned to line so I can parse and use it?