Ok great. Thank you again.
What is 'control_points' in the output variable?
I tried running and it seems to have failed to read the lat/longs...try: arcpy.MakeXYEventLayer_management(xls, 'LONGITUDE', 'LATITUDE', layer) arcpy.CopyFeatures_management(layer, output) print 'Feature Class Created'
EDIT: I think I figured out why it cant read the XY data. My guess is one of 2 things, or maybe both.
1. The table is setup as all VLOOKUP values in excel. It just pulls values from other sheets within the file.
2. Since it is setup as VLOOKUPs, there is a reference number field for row 1, and then the field names in row 2.
Im guessing one of those things is causing it to be unable to plot those values.
import arcpy, os, sys, traceback from os import path as p arcpy.env.workspace = ws = r'C:\Documents\DatabaseData' arcpy.env.overwriteOutput = True arcpy.env.outputCoordinateSystem = arcpy.SpatialReference('WGS 1984') # Variables xls = r'Y:\Strategy by Market Reports and Data\Darden Master SBM Table.xlsx\LHGIS$' layer = 'LongHornSBM' outfold = r'C:\Documents\ArcGIS\DardenMaster.gdb' output = p.join(outfold, 'LongHornSBM') try: arcpy.MakeXYEventLayer_management(xls, 'LONGITUDE', 'LATITUDE', layer) arcpy.CopyFeatures_management(layer, output) print 'Feature Class Created' except: # Get the traceback object tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] # Concatenate information together concerning the error into a message string pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n" # Return python error messages for use in script tool or Python Window arcpy.AddError(pymsg) arcpy.AddError(msgs) # Print Python error messages for use in Python / Python Window print pymsg + "\n" print msgs
arcpy.TableToTable_conversion (layer, outfold, 'LongHornSBM')
how can we add layer into TOC or map document i have tried by doing
arcpy.MakeXYEventLayer_management(xls, 'EASTING', 'NORTHING', layer, spa_ref)
arcpy.SetParameter(0,"control_points")
pmxd = arcpy.mapping.MapDocument("CURRENT")
pdf = arcpy.mapping.ListDataFrames(pmxd)[0]
arcpy.mapping.AddLayer(pdf,)
arcpy.CopyFeatures_management(layer, output)
print 'Feature Class Created'
but its not working
I'm a bit late to the party, but I have been trying to iterate from an active XLS sheet to my shapefile. I have had no luck trolling through ESRI help sites etc, which simply astounds me (i.e. that I cannot update an Excel sheet and simply update the shapefile to read in the changes).
I don't do well with scripting, also it doesn't resolve my dilemma of having to reformat my point data style each time, which is an additional tedious step.
Has there been any progress on this function? It would seem to me to be a trivial function, but I've had no luck cracking it without introducing multiple complexities.
Thanks.