Broken Script Fix
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have this script which gives me an attribute error and points out line 8.
The error says
" 'list' object has no attribute 'name'"
Not sure what went wrong. How do I fix this script to run?
import arcpy
from arcpy import env
env.workspace = "C:/EsriPress/Python/Data/MyFolder"
fc = "airports.shp"
rows = arcpy.SearchCursor(fc)
fields = arcpy.ListFields(fc)
for field in fields:
if fields.name == "NAME":
for row in rows:
print "Name = (0".format(row.getValue(field.name))
arcpy python
New contributor
add a comment |Â
up vote
1
down vote
favorite
I have this script which gives me an attribute error and points out line 8.
The error says
" 'list' object has no attribute 'name'"
Not sure what went wrong. How do I fix this script to run?
import arcpy
from arcpy import env
env.workspace = "C:/EsriPress/Python/Data/MyFolder"
fc = "airports.shp"
rows = arcpy.SearchCursor(fc)
fields = arcpy.ListFields(fc)
for field in fields:
if fields.name == "NAME":
for row in rows:
print "Name = (0".format(row.getValue(field.name))
arcpy python
New contributor
What is you tried if field.name == "NAME": in your code.
â Keagan Allan
1 hour ago
That worked like a charm!!!!!!!!!!!!!!!!!!!
â dvldgs05
55 mins ago
@dvldgs05 please accept Keagan's answer if it worked for you.
â Fezterâ¦
45 mins ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have this script which gives me an attribute error and points out line 8.
The error says
" 'list' object has no attribute 'name'"
Not sure what went wrong. How do I fix this script to run?
import arcpy
from arcpy import env
env.workspace = "C:/EsriPress/Python/Data/MyFolder"
fc = "airports.shp"
rows = arcpy.SearchCursor(fc)
fields = arcpy.ListFields(fc)
for field in fields:
if fields.name == "NAME":
for row in rows:
print "Name = (0".format(row.getValue(field.name))
arcpy python
New contributor
I have this script which gives me an attribute error and points out line 8.
The error says
" 'list' object has no attribute 'name'"
Not sure what went wrong. How do I fix this script to run?
import arcpy
from arcpy import env
env.workspace = "C:/EsriPress/Python/Data/MyFolder"
fc = "airports.shp"
rows = arcpy.SearchCursor(fc)
fields = arcpy.ListFields(fc)
for field in fields:
if fields.name == "NAME":
for row in rows:
print "Name = (0".format(row.getValue(field.name))
arcpy python
arcpy python
New contributor
New contributor
edited 1 hour ago
Keagan Allan
2,1201416
2,1201416
New contributor
asked 1 hour ago
dvldgs05
61
61
New contributor
New contributor
What is you tried if field.name == "NAME": in your code.
â Keagan Allan
1 hour ago
That worked like a charm!!!!!!!!!!!!!!!!!!!
â dvldgs05
55 mins ago
@dvldgs05 please accept Keagan's answer if it worked for you.
â Fezterâ¦
45 mins ago
add a comment |Â
What is you tried if field.name == "NAME": in your code.
â Keagan Allan
1 hour ago
That worked like a charm!!!!!!!!!!!!!!!!!!!
â dvldgs05
55 mins ago
@dvldgs05 please accept Keagan's answer if it worked for you.
â Fezterâ¦
45 mins ago
What is you tried if field.name == "NAME": in your code.
â Keagan Allan
1 hour ago
What is you tried if field.name == "NAME": in your code.
â Keagan Allan
1 hour ago
That worked like a charm!!!!!!!!!!!!!!!!!!!
â dvldgs05
55 mins ago
That worked like a charm!!!!!!!!!!!!!!!!!!!
â dvldgs05
55 mins ago
@dvldgs05 please accept Keagan's answer if it worked for you.
â Fezterâ¦
45 mins ago
@dvldgs05 please accept Keagan's answer if it worked for you.
â Fezterâ¦
45 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
From the code provided, I tested the following:
Your if Statement is looking at "Fields"
You want the if statement to look at the Field in the list of Fields.
Change:
if fields.name == "NAME":
to
if field.name == "NAME":
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
From the code provided, I tested the following:
Your if Statement is looking at "Fields"
You want the if statement to look at the Field in the list of Fields.
Change:
if fields.name == "NAME":
to
if field.name == "NAME":
add a comment |Â
up vote
2
down vote
From the code provided, I tested the following:
Your if Statement is looking at "Fields"
You want the if statement to look at the Field in the list of Fields.
Change:
if fields.name == "NAME":
to
if field.name == "NAME":
add a comment |Â
up vote
2
down vote
up vote
2
down vote
From the code provided, I tested the following:
Your if Statement is looking at "Fields"
You want the if statement to look at the Field in the list of Fields.
Change:
if fields.name == "NAME":
to
if field.name == "NAME":
From the code provided, I tested the following:
Your if Statement is looking at "Fields"
You want the if statement to look at the Field in the list of Fields.
Change:
if fields.name == "NAME":
to
if field.name == "NAME":
answered 1 hour ago
Keagan Allan
2,1201416
2,1201416
add a comment |Â
add a comment |Â
dvldgs05 is a new contributor. Be nice, and check out our Code of Conduct.
dvldgs05 is a new contributor. Be nice, and check out our Code of Conduct.
dvldgs05 is a new contributor. Be nice, and check out our Code of Conduct.
dvldgs05 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%2f298266%2fbroken-script-fix%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
What is you tried if field.name == "NAME": in your code.
â Keagan Allan
1 hour ago
That worked like a charm!!!!!!!!!!!!!!!!!!!
â dvldgs05
55 mins ago
@dvldgs05 please accept Keagan's answer if it worked for you.
â Fezterâ¦
45 mins ago