Apr-22-2020, 02:35 PM
generally the idea is that you should include as little code as possible in the try block (i.e. be precise and handle the error where it can happen).
The change you did will catch KeyError if the csv file header does not have 'dev_model' or 'host_ip' and will print error message for each line in the file. I doubt you want this. If you want to check the header, do it before the loop.
The change you did will catch KeyError if the csv file header does not have 'dev_model' or 'host_ip' and will print error message for each line in the file. I doubt you want this. If you want to check the header, do it before the loop.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs