# import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:\Users\Ewan\Desktop\SFTPDST5\MapFiles"

try:
    # Set the local variable

    in_Table = "Trees.csv"
    x_coords = "X"
    y_coords = "Y"
    z_coords = "Z"
    out_Layer = "Trees_Layer"
    saved_Layer = "C:\Users\Ewan\Desktop\SFTPDST5\Mapfiles\Trees.lyr"

    # Set the spatial reference
    spRef = r"Coordinate Systems\Geographic Coordinate Systens\World\WGS 1984.prj"

    # Make the XY Event Layer
    arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_Layer, spRef)

    # Save to a layer file
    arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)

except Exception as err:
    print(err.args[0])