Condition if column from table is empty is not working?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I want to make a loop where if a column is empty in a row to do something else. The problem is that it can't determine the empty row. I tried as null, na , '',' ' and with double quotes and nothing.
for i in t_list:
with arcpy.da.SearchCursor(i, ["name","num"]) as cur:
for row in cur:
if row[1] is not "''":
print(row)
Gives:
nog1, num = '1'
nog2, ''
And it returns even the the empty rows
arcpy cursor null
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
I want to make a loop where if a column is empty in a row to do something else. The problem is that it can't determine the empty row. I tried as null, na , '',' ' and with double quotes and nothing.
for i in t_list:
with arcpy.da.SearchCursor(i, ["name","num"]) as cur:
for row in cur:
if row[1] is not "''":
print(row)
Gives:
nog1, num = '1'
nog2, ''
And it returns even the the empty rows
arcpy cursor null
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to make a loop where if a column is empty in a row to do something else. The problem is that it can't determine the empty row. I tried as null, na , '',' ' and with double quotes and nothing.
for i in t_list:
with arcpy.da.SearchCursor(i, ["name","num"]) as cur:
for row in cur:
if row[1] is not "''":
print(row)
Gives:
nog1, num = '1'
nog2, ''
And it returns even the the empty rows
arcpy cursor null
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I want to make a loop where if a column is empty in a row to do something else. The problem is that it can't determine the empty row. I tried as null, na , '',' ' and with double quotes and nothing.
for i in t_list:
with arcpy.da.SearchCursor(i, ["name","num"]) as cur:
for row in cur:
if row[1] is not "''":
print(row)
Gives:
nog1, num = '1'
nog2, ''
And it returns even the the empty rows
arcpy cursor null
arcpy cursor null
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago
PolyGeo♦
52.2k1779236
52.2k1779236
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 1 hour ago
user51332
82
82
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
user51332 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
To check for not na/none use:
if row[1] is not None
To check for both None and empty string use:
if row[1] not in ('', None)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
To check for not na/none use:
if row[1] is not None
To check for both None and empty string use:
if row[1] not in ('', None)
add a comment |Â
up vote
3
down vote
accepted
To check for not na/none use:
if row[1] is not None
To check for both None and empty string use:
if row[1] not in ('', None)
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
To check for not na/none use:
if row[1] is not None
To check for both None and empty string use:
if row[1] not in ('', None)
To check for not na/none use:
if row[1] is not None
To check for both None and empty string use:
if row[1] not in ('', None)
edited 1 hour ago
answered 1 hour ago


BERA
12.6k51737
12.6k51737
add a comment |Â
add a comment |Â
user51332 is a new contributor. Be nice, and check out our Code of Conduct.
user51332 is a new contributor. Be nice, and check out our Code of Conduct.
user51332 is a new contributor. Be nice, and check out our Code of Conduct.
user51332 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f300302%2fcondition-if-column-from-table-is-empty-is-not-working%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password