row
is just a variable name in this context. When you do if row
, you actually checking if there is any content to the variable that python considers to be True
.
Take a look at this answer from Patrick Haugh in which he highlights lots of examples of what is Falsy
in python.
To illustrate in a minimal example:
import csv
for row in csv.reader(['row1,foo','', 'row3,bar']):
print(row)
yields
['row1', 'foo']
[]
['row3', 'bar']
But if you do
for row in csv.reader(['row1,foo','', 'row3,bar']):
if row:
print(row)
Then output is
['row1', 'foo']
['row3', 'bar']
and thus basically the empty row is filtered out.