Reading this post didn't really answer my question.
I have a
reader = csv.reader(source)
for row in reader:
if len(row[0]) > 23:
# Do stuff
continue
if low > float(row[1]) > high:
# Do stuff
continue
if low > float(row[2]) > high:
# Do stuff
continue
else:
print('All', reader.line_num, 'read successfully.')
setup, but the else
is executed despite me skipping in the for
loop.
I'd rather that the else was only called if no continue
was hit.
In order to clarify, the purpose of the code is to drop bad/malformed data rows in the CSV file. As such, malformed lines have individual error handling. Using 'else' as final notifier would, if possible be much more beautiful than working with flags.