I have done this hundreds of times, but something seems to have changed in the last Arc Pro update. I have a Python script where I am trying to convert a spreadsheet into a point layer. Below is what I tried first, but the latitude and longitude fields will not convert to Double.
# Process: Excel To Table (Excel To Table) (conversion)
arcpy.AddMessage("Converting spreadsheet to DB Table")
logging.info("Converting spreadsheet to DB Table")
excelToTable = os.path.join(TempWS, "excelToTable")
arcpy.AddMessage("Excel to table path " + excelToTable)
arcpy.conversion.ExcelToTable(Input_Excel_File=spreadsheet, Output_Table=excelToTable, Sheet="Debris Harvest Data Florida")
fm = ("list_name \"List Name\" true true false 100 Text 0 0,First,#,excelToTable,list_name,0,254;" +
"item_id \"Item ID\" true true false 10 Text 0 0,First,#,excelToTable,item_id,0,254;" +
"itemname \"Item Name\" true true false 255 Text 0 0,First,#,excelToTable,itemname,0,254;" +
"material \"Material\" true true false 255 Text 0 0,First,#,excelToTable,material,0,254;" +
"quantity \"Quantity\" true true false 255 Text 0 0,First,#,excelToTable,quantity,0,254;" +
"description \"Description\" true true false 255 Text 0 0,First,#,excelToTable,description,0,254;" +
"latitude \"Latitude\" true true false 8 Double 0 0,First,#,excelToTable,latitude,0,254;" +
"longitude \"Longitude\" true true false 8 Double 0 0,First,#,excelToTable,longitude,0,254;" +
"altitude \"Altitude\" true true false 255 Float 0 0,First,#,excelToTable,altitude,0,254;" +
"radius \"Radius\" true true false 255 Float 0 0,First,#,excelToTable,radius,0,254;" +
"location \"Location\" true true false 255 Text 0 0,First,#,excelToTable,location,0,254;" +
"timestamp \"Timestamp\" true true false 255 Text 0 0,First,#,excelToTable,timestamp,0,254;" +
"dt \"Datetime\" true true false 255 Date 0 0,First,#,excelToTable,dt,0,254;" +
"project_name \"Project Name\" true true false 255 Text 0 0,First,#,excelToTable,project_name,0,254;" +
"project_id \"Project ID\" true true false 255 Long 0 0,First,#,excelToTable,project_id,0,254;" +
"username \"Username\" true true false 255 Text 0 0,First,#,excelToTable,username,0,254;" +
"user_index \"User Index\" true true false 255 Long 0 0,First,#,excelToTable,user_index,0,254;" +
"manual_upload \"Manual Upload\" true true false 255 Text 0 0,First,#,excelToTable,manual_upload,0,254;" +
"event_name \"Event Name\" true true false 255 Text 0 0,First,#,excelToTable,event_name,0,254;" +
"id \"ID\" true true false 255 Text 0 0,First,#,excelToTable,id,0,254;" +
"log_index \"Log Index\" true true false 255 Long 0 0,First,#,excelToTable,log_index,0,254")
# Process: Export Table (Export Table) (conversion)
arcpy.AddMessage("Exporting table and mapping fields")
logging.info("Exporting table and mapping fields")
MDD_exportTable = os.path.join(TempWS, "MDD_exportTable")
arcpy.conversion.ExportTable(in_table=excelToTable, out_table=MDD_exportTable, field_mapping=fieldMap)
# Process: XY Table To Point (XY Table To Point) (management)
arcpy.AddMessage("Displaying XY values and creating point feature class")
logging.info("Displaying XY values and creating point feature class")
MDD_tableToPoint = os.path.join(TempWS, "MDD_tableToPoint")
arcpy.management.XYTableToPoint(in_table=MDD_exportTable, out_feature_class=MDD_tableToPoint, x_field="lon", y_field="lat",
coordinate_system="GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision")
In the exported table, the latitude and longitude fields are still Text fields and I cannot display XY values using these fields. I also tried adding new fields in the field map and then calculating them, but iy seems as though the Table Export tool is ignoring the field mapping altogether because there are no new fields created to run the Calculate Field tool on. I noticed that in the last ArcPro update, the field mapping tool interface has changed, so I am wandering if something got messed up in the last update. I really don't want to have to write an extra 100 lines of code to do this, so if anyone has any insight please share. 🙂