AnsweredAssumed Answered

Arcpy InsertCursor Issue

Question asked by jtapane1_GISandData on Feb 8, 2019
Latest reply on Feb 11, 2019 by jtapane1_GISandData

Hey all,


I have some text files with x,y coordinates in them. I created a script that finds the specific .txt files that I want and then puts them in a list. Then it creates corresponding EMPTY feature classes for them. I'm trying to use an insertcursor to populate the empty feature classes with the contents of the text files. However, I'm stuck on this part. Here is the portion of my script that is not working:


# puts the empty feature classes in a list.

fclist = arcpy.ListFeatureClasses()


for fc in fclist:
      cursor = arcpy.da.InsertCursor(fc, ["SHAPE@"])
      array = arcpy.Array()

#text_Points is the list of the txt files.

      for file in text_Points:
            desc = arcpy.Describe(file)
            desc1 = arcpy.Describe(fc)
            if desc.basename == desc1.basename:
                print "yes"
                for line in fileinput.input(file):
                     ID, X, Y = string.split(line, " ")
                     array.add(arcpy.Point(X, Y))
                     del cursor
               print "error"



I'm grateful for any pointers. Thanks.