AnsweredAssumed Answered

Error 000728 when trying to read from CSV to XYEventLayer

Question asked by pinghanling on Oct 18, 2016
Latest reply on Oct 20, 2016 by pinghanling

Hi,

 

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:

Easting,Northing,Time,PingNo
93472.9,3657803.3,105530,47701
93453.0,3657772.8,105545,47760
93449.5,3657739.5,105600,47820

 

The code I'm using is:

import glob, os, csv, arcpy

inFolder = r'C:\temp'

 

# Set environment settings
arcpy.env.workspace = inFolder

 

def makePoints(inTable,lineName):
    try:
    # 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:

        print(err.args[0])


def main():
    # create points layer from temporary csv file
    makePoints('temp.csv',lineName)


if __name__ == '__main__':
    main()

 

Thanks

Hanlie

Outcomes