AnsweredAssumed Answered

Using SearchCursor to extract x,y data and send to a file but also want to take other attribute info

Question asked by roberteg7108 on May 1, 2018
Latest reply on May 1, 2018 by bixb0012

Hi there

Fairly new to python and Arc but I want to use a SearchCursor to extract the x,y from the geometry of a shp file and create a excel file, but I also want to take other attribute information so I can search and replace later on.

 

How do I take the other attribute info out to the file as well as the coordinate information?

 

import arcpy

infc = "H:\GIST_8125\Oil_Gas\Gail_test\clip_project.shp"
cursor = arcpy.da.SearchCursor(infc, ["GRID","SECTION","UNIT","OID@","SHAPE@"])
with open('H:\GIST_8125\Oil_Gas\Gail_test\Results.txt', 'w') as output:
for row in cursor:
print ("{0}, {1}, {2}".format(row[0]))
for point in row[1].getPart(0):
print ("{0}, {1}, {2}".format(point.X, point.Y))
output.write(str(point.X)+" , "+str(point.Y)+"\n")

 

Thanks in advance

Gail

Outcomes