I am having an issue with this bit of python. Basically I open up a cursor to loop through a feature class. At each row, I take every field and put the values in a dictionary. I then append this to a list. I am specifically interested in ObjectID and SHAPENext I unpack the list of dictionaries and print the ObjectID and SHAPE.For some reason the SHAPE component isn???t saved properly. But the ObjectID is. I think this is a bug with ArcPy, but it could just as likely be a bug with my code.I get the following output:1 - -8359910.19268255 4842313.47802997 NaN NaN2 - -8353926.32475581 4846897.25034694 NaN NaN3 - -8359087.54168308 4842848.29488585 NaN NaN************1 - -8359087.54168308 4842848.29488585 NaN NaN2 - -8359087.54168308 4842848.29488585 NaN NaN3 - -8359087.54168308 4842848.29488585 NaN NaN
import arcpy
fc = r'C:\Users\cfricke.GISINC\Documents\BOMBED\Test.gdb\Stores'
cursor = arcpy.SearchCursor(fc)
fields = arcpy.ListFields(fc)
geo = arcpy.Describe(fc).ShapeFieldName
idField = arcpy.Describe(fc).OIDFieldName
###
# Part A
# Output Cursor into List of Dictionaries
# Print ObjectID and Shape at each iteration
###
fcList = []
for row in cursor:
fcDict = {}
for field in fields:
fcDict[field.name] = row.getValue(field.name)
if field.name == geo:
print "%s - %s" % (row.getValue(idField), row.getValue(field.name).getPart())
fcList.append(fcDict)
del fcDict
print ""
print "************"
print ""
###
# Part B
# Loop through list of dictionary, print objectID and shape
###
for x in fcList:
print "%s - %s" % (x[idField],x[geo].getPart())
del fcList