I am using ArcPy to create an output feature layer. I am using the command:
arcpy.MakeXYEventLayer_management(wells, "longitude", "latitude", wells_layer, GEOGCS, ""),
where wells is my input csv file and wells_layer is the path for the output feature layer. The idea is that after creating this feature class I will convert it to a shape file using arcpy.FeatureClassToShapefile_conversion
. The issue is that when I try to run the first command
arcpy.MakeXYEventLayer_management(wells, "longitude", "latitude", wells_layer, GEOGCS, ""),
I get error 000212 : Cannot create XY event source:
Error:File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 6589,
in MakeXYEventLayer raise e arcgisscripting.ExecuteError: ERROR 000212:
Cannot create XY event source Failed to execute (MakeXYEventLayer).
The weird thing is that I am running this command on around 50 numbered csv files which have been created in Stata using a for loop. Therefore, the formatting and structure of these files is precisely the same. However, this error only occurs for files numbered 15 and above. For files 1-14 this command works perfectly. I am at a complete loss because there seems to be no difference between these files.
I checked the ArcGIS help section and it says that I should check paths, field names and whether the coordinates are numeric. All of these appear to be fine across all the files.
I am using Python 2.7 and Arc Gis 10.2
I have detected with some help in comments that ArcMap is not detecting the latitude field for files 15 onwards. This is strange because the formatting is consistent and there are no spaces etc.
The field names in the csv are in top row as follows:
id_no,latitude,longitude