- let's not iterate directly (always possible, of course) on the CSV reader
object, but generate a list from its rows
- this also allow us to check if 'reader' is not NoneType
reader = csv.DictReader(response.content.decode("utf-8").splitlines(), dialect="unix")
logger.debug("reader[]='%s'", type(reader))
- for row in reader:
+ if reader is None:
+ logger.warning("Failed parsing response.content()=%d as CSV content", len(response.content))
+ return 2
+
+ rows = list(reader)
+
+ logger.info("Checking %d rows ...", len(rows))
+ for row in rows:
logger.debug("row[]='%s'", type(row))
if "hostname" not in row:
logger.warning("row()=%d has no element 'hostname' - SKIPPED!", len(row))