Select to view content in your preferred language

Trying to Create Feature Class - Error Executing Function

2126
1
04-26-2013 01:47 PM
MikeVann
New Contributor
Hi

I'm working on a project of converting a csv table into ArcMap readable shapefiles. I have set parameters for the Create Feature Class tool, but am getting an "error executing function" message (error 999999). I've tried setting different parameters(I'm using default parameters which I indicate with #), but keep getting this message. I also created an xy event layer before running Create Feature ClassAny other ideas?

Thanks,
Mike

data = []
inFile = open(inputFile, 'r')
outFile = open(outputFile, 'w')

count = 0
for n in range(6):
    count = count + 1
    line = inFile.readline()

while line:
    count = count + 1
    line = inFile.readline()
    print 'Row', count, 'line info=', line[:72]
    lineList = line.split(',')
    newList = lineList[:72]
    print 'line info =', newList  
    newLine = ','.join(newList)
    newLine = newLine + '\n'
    formatLine = newLine.replace("/","_")
    outFile.write(formatLine) 

table = outputFile
in_x_field = "LongitudeNAD83"
in_y_field = "LatitudeNAD83"
out_layer = "xyLayer.lyr"
spatial_reference = arcpy.SpatialReference("Coordinate Systems/Geographic Coordinate Systems/North America/NAD 1983.prj")
arcpy.MakeXYEventLayer_management(table, in_x_field, in_y_field, out_layer, spatial_reference)

out_path = os.path.dirname(outputFile)
out_name = outputFile[:-4] + ".shp"
geometry_type = "POINT"
spatial_reference = arcpy.SpatialReference("Coordinate Systems/Geographic Coordinate Systems/North America/NAD 1983.prj")
arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, "#", "#", "#", spatial_reference, "#", "#", "#", "#")
0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
Hi Mike,

I believe the problem is with your 'out_name' variable.  You are setting this to a full path, i.e "C:\Temp\XY.shp".  The tool requires that you simply specify the Feature Class/Shapefile Name, i.e. "XY.shp".

Try setting the out_name variable to the following:

out_name = outputFile.split("\\")[-1][:-4] + ".shp"
0 Kudos