I am trying to create a table as part of a script tool, and it always fails with error 999999.
The general idea of the script is that it is calculating proportional coverage of things in a series of buffers, and the tables are needed to compile the results.
The code I'm using creates the tables and works fine in PyScripter and also works fine in the Python window within ArcMap, but will not run as a tool and fails at the create tables part.
I'm not sure if part of the problem is that I'm trying to access the path names and files via the GetParamtersAsText function or not. I have tried countless ways of naming the outputs in the CreateTable_management function. I'm not sure what I am missing here (maybe I need output parameters).
Here is my code (the relevant parts of creating the tables):
import arcpy import os #set up workspace location Working = arcpy.GetParametersAsText(0) #user provided geodatabase location arcpy.env.workspace = Working arcpy.env.overwriteOutput = True #set up link to buffer files. Buff50_R = arcpy.GetParameterAsText(3) #user provided: let's pretend file is called 'RightBufferfile' Buff50_L = arcpy.GetParameterAsText(4) #user provided: let's pretend file is called 'LeftBufferfile' #Loop through and make table based on the name of each of the buffers for each metric of interest #When I use PyScripter or the Python window in ArcMap the tables are created in the working #geodatabase and are named 'InC1RightBufferfile', InC1LeftBufferfile', etc... fcList =[Buff50_R, Buff50_L] for eachFC in fcList: NatVeg_Table = "InC1" + eachFC ##Blank file for any natural veg within each buffer arcpy.CreateTable_management(Working, NatVeg_Table) arcpy.AddField_management(NatVeg_Table, "BID", "TEXT", 12) arcpy.AddField_management(NatVeg_Table, "SUM_Per_Cov","DOUBLE", 20, 4) NatForest_Table = "InC2" + eachFC ##Blank file for any forest within each buffer scale arcpy.CreateTable_management(Working, NatForest_Table) arcpy.AddField_management(NatForest_Table, "BID", "TEXT", 12) arcpy.AddField_management(NatForest_Table, "SUM_Per_Cov","DOUBLE", 20, 4) HumanDev_Table = "InC3" + eachFC ##Blank file for any Human Disturbance within each buffer scale arcpy.CreateTable_management(Working, HumanDev_Table) arcpy.AddField_management(HumanDev_Table, "BID", "TEXT", 12) arcpy.AddField_management(HumanDev_Table, "Per_Cov","DOUBLE", 20, 4)
I've tried using Delete_management to delete the table ahead of creating the table with no luck, and have tried commenting out the first table, but get then get the same error starting with the NatForest_Table.
Here are the parameter configurations; the buffer files correspond to parameters 3 and , and all the input feature classes are configured the same way.