i have found some errors but im sure not everything. what errors can you see in these?
import arcpy
from arcpy import env
env.workspace = "C:/EsriPress/Python/Data/Exercise07"
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))
import arcpy
from arcpy import env
env.workspace = "C:/EsriPress/Python/Data\Exercise09"
raster = "landcover.tiff"
desc = arcpy.describe(raster)
x = desc.MeanCellHeight
y = desc.MeanCellWidth
spatialref = desc.spatialReference
units = spatialref.linearUnitName
print "Cells are" + str(x) + " by " + str(y) + " " + units + "."
Solved! Go to Solution.
import arcpy
#from arcpy import env
#i prefer to be explicit in module use
#use raw formatting
arcpy.env.workspace = r"C:/EsriPress/Python/Data/Exercise07"
#lower case
#is this in the workspace? if not use a full path
fc = "airports.shp"
#arcpy.da.searchcursor is best
#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))
try:
with arcpy.da.SearchCusor(fc, "NAME") as cursor:
for row in cursor:
print("Name = " + row)
except:
print("No field 'NAME' found")
break
Try following steps in this link to present your code block:
https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet
Can you also show the error messages that you are getting?
its an exercise i didnt create these scripts.
Show your results, someone else's samples aren't going to help if you don't have error messages.
import arcpy
#from arcpy import env
#i prefer to be explicit in module use
#use raw formatting
arcpy.env.workspace = r"C:/EsriPress/Python/Data/Exercise07"
#lower case
#is this in the workspace? if not use a full path
fc = "airports.shp"
#arcpy.da.searchcursor is best
#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))
try:
with arcpy.da.SearchCusor(fc, "NAME") as cursor:
for row in cursor:
print("Name = " + row)
except:
print("No field 'NAME' found")
break