I'm trying to convert a CSV file to an XY layer using arcpy.MakeXYEventLayer_management but I'm getting an error:
ERROR 000728: Field Easting does not exist within table
ERROR 000728: Field Northing does not exist within table
I can't figure out why I'm getting this error. Can someone please help me?
These are the headings and the first three records of my CSV file (temp.csv), which is in the C:\temp folder:
The code I'm using is:
import glob, os, csv, arcpy
inFolder = r'C:\temp'
# Set environment settings
arcpy.env.workspace = inFolder
# Set the local variables
in_Table = inTable
x_coords = 'Easting'
y_coords = 'Northing'
out_Layer = 'points_layer'
saved_Layer = os.path.join(inFolder, 'points.lyr')
# Set the spatial reference to UTM 34S
spRef = arcpy.SpatialReference(32734)
# Make the XY event layer...
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_Layer, spRef)
except Exception as err:
# create points layer from temporary csv file
if __name__ == '__main__':