I have python code that loops over a file. I'm getting a UTF-8 error (invalid continuation byte)
when I read over the file. I just want my program to ignore that.
I've tried using a try except around the code inside, but that won't work since the error is in the condition of the for loop. I've also tried using a try except around the loop but then when it catches the error it doesn't start the loop again.
with open(input_file_path, "r") as input_file:
for line in input_file:
# code irrelevant to question
What happens is it gives this error on for line in input_file
:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 5: invalid continuation byte`
I want it to skip that line and move to the next one. Essentially, a try catch on the condition of my for loop.