@Adrian
You probably need to add an except. See this thread and this thread for some possible ways to handle this in python. More helpful information on KeyErrors here.
Hope this helps. Let us know if you have further questions or issues.
-------------------------------
Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.