AnsweredAssumed Answered

Can't get the workspace set correctly,  or it's something else.

Question asked by huffmanp on May 2, 2014
Latest reply on May 30, 2014 by huffmanp
Last week I was rearranging the attribute tables of a bunch of shapefiles.  It was working fine. It looked like this:
# Import arcpy module import arcpy from arcpy import env env.workspace = "C:\\avdata\\FallChinookRedds\\2013\\Shapefiles\\"  # Local variables: inshape = "MDhighway972211113.shp" fname = "\""+inshape+"\"" surdate = "\"11/01/2013\"" streamname = "\"Yakima River\"" specname = "\"Fall Chinook\""  # Process: Delete Field arcpy.DeleteField_management(inshape, "TYPE;Y_PROJ;X_PROJ;DISPLAY;SYMBOL;UNUSED1;DIST;PROX_INDEX;COLOR;DEPTH;TEMP;TIME;WPT_CLASS;SUB_CLASS;ATTRIB;LINK;STATE;COUNTRY;CITY;ADDRESS;FACILITY;CROSSROAD;UNUSED2;ETE;DTYPE;MODEL")  #more steps ......


Most of the time I was editing python, changing the shapefile name, then dragging the code from IDLE to the ArcMap python window so I could keep the map open and not hit schema locks. 

This week I was doing the same thing to some 2012 shapefiles.  I thought all I had to do was change the workspace env variable and it would work the same:
# Import arcpy module import arcpy from arcpy import env env.workspace = "C:\\avdata\\FallChinookRedds\\"  # Local variables: inshape = "2zillTOgra102312.shp" fname = "\""+inshape+"\"" surdate = "\"10/23/2012\"" streamname = "\"Yakima River\"" specname = "\"Fall Chinook\""  # Process: Delete Field arcpy.DeleteField_management(inshape, "TYPE;Y_PROJ;X_PROJ;DISPLAY;SYMBOL;UNUSED1;DIST;PROX_INDEX;COLOR;DEPTH;TEMP;TIME;WPT_CLASS;SUB_CLASS;ATTRIB;LINK;STATE;COUNTRY;CITY;ADDRESS;FACILITY;CROSSROAD;UNUSED2;ETE;DTYPE;MODEL") #more steps .....


but in the python window I get "ERROR 000732: Input Table: Dataset 2zillTOgra102312.shp does not exist or is not supported Failed to execute (DeleteField).  " as soon as it hits that first DeleteField, as if the file name or path is wrong.  However if I print env.workspace in the python window, I get the path I expect. And if I type listshapes = arcpy.ListFeatureClasses() , listshapes is filled with all the shapefiles in the workspace. Tried several other input shapefiles, but got the same type of error.

The script for 2012 data works when I run it in python, but I have to shut down ArcMap and ArcCatalog to avoid hitting schema locks.  What am I missing when I try to run this in the python window?

Outcomes