I'm having trouble finding a way to write the output of a SearchCursor function to a txt. file. I can print it just fine in a format that is desirable. I just don't know how to get from there to a txt. file. Here's my code below:
import arcpy from arcpy import env env.workspace = "G:\Geocomputation_Project\Section C\Lin_Ref_test" shape = "Points.shp" cursor = arcpy.SearchCursor(shape) f = open("test_field.txt", "w") for row in cursor: print (row.getValue("ITEMID")),(row.getValue("New_X_LRR")), (row.getValue("New_Y_LRR")) print "done"
The txt file does not yet exist. When I start running this script, I hope to be able to overwrite the text file as I do more iterations.
I am using ArcMap 10.2.2