AnsweredAssumed Answered

arcpy create feature class from csv/xy event layer where one field has more than 255 characters

Question asked by bagpipemike on Feb 10, 2017
Latest reply on Feb 10, 2017 by bixb0012

I'm writing a Python script that will take a csv containing point data, create an xy event layer from the csv and then create a file geodatabase feature class from that xy event layer (and then will do some more things with the feature class). One of the text fields in the csv has entries that in some cases have more than 255 characters and I'm struggling to work out how to get the csv/xy event layer to convert to a file geodatabase feature class.


I had thought to use the arcpy.CopyFeatures_management tool but it won't work with the entries that have more than 255 characters.


I next looked into manually creating an empty feature class with all of the fields already in it (editing the length of that one field to contain 1,000 characters) and use the arcpy.Append_management tool to append the features into feature class but the append tool won't take an xy event layer as the input.


I have the empty feature class created with the field length edited to contain 1,000 characters so I've also tried to use cursor.insertRow to insert the features from the xy event layer in to the empty feature class but I'm getting an error I think when I define the cursor:


cursor = arcpy.da.InsertCursor("D:\\GISData\\AccidentAnalysis\\AccidentAnalysis.gdb\\aa13To16", "*")


Perhaps this is the way to go but I've not used the cursor much and I can't figure out why this isn't working.


I'm looking for other ways to get this csv converted to a feature class but haven't found one yet. Any suggestions? Or any advice on how to get the cursor.insertRow to work?





Edit: arcpy code:


import arcpy


sr = arcpy.SpatialReference(27700)


inputCsv = "D:\\GISData\\AccidentAnalysis\\TestData.csv"


aaLayer = "aaLayer"
arcpy.MakeXYEventLayer_management(inputCsv, "easting", "northing", aaLayer, sr)


cursor = arcpy.da.InsertCursor("D:\\GISData\\AccidentAnalysis\\AccidentAnalysis.gdb\\aa13To16", "*")


for feature in aaLayer:


del cursor