Hello everyone, I'm working on creating a tool that will allow me to select multiple tables from an Access Database and convert them to standalone tables in a Geodatabase:
I created a .odc database connection to the Access database the tables are being stored in hopes to make it easier to select the tables. Here is the script that I have so far:
import arcpy
import os
#Allow code to overwrite existing datasets
arcpy.env.overwriteOutput = True
#Set the variables
workspace = r"C:\UpdateDevelopmentPython\ForDeveloping\isrb_business.odc"
tables = arcpy.GetParameterAsText(0).split(";")
outpath = r"C:\UpdateDevelopmentPython\ForDeveloping\ForDeveloping.gdb"
outfile = os.path.join(workspace, "{}" .format(os.path.join(workspace) + str(["baseName"])))
#Create the standalone tables
TblResponseID = arcpy.TableToTable_conversion(tables,outpath,outfile)
However whenever I run the the tool I keep getting this message.
Solved! Go to Solution.
The parameters for the TableToTable are not right. It is expecting an input table, the output path, and just the output table name. You have a full path (and string of a list "baseName") going into the table name parameter.
Set your code up in a loop to iterate over the list of tables you get and you can grab the name of each table for the output. Like Don mentioned, add some print statements or set some breakpoints and debug so you can see what your variables look like.
tables = arcpy.GetParameterAsText(0).split(';')
outpath = r"C:\UpdateDevelopmentPython\ForDeveloping\ForDeveloping.gdb"
for tble in tables:
baseName = os.path.basename(table)
#Create the standalone tables
TblResponseID = arcpy.TableToTable_conversion(tble, outpath, baseName)
I actually don't see the error message - I do see the source code in red - is that what you are calling the error message?
Also:
Hi Don I copied and pasted the wrong thing lol
Traceback (most recent call last):
File "C:\UpdateDevelopmentPython\DevelopmentScripts\PublishFireStationWithType.py", line 13, in <module>
Tbls = arcpy.TableToTable_conversion(tables,outpath,["baseName"])
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 3112, in TableToTable
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 3109, in TableToTable
retval = convertArcObjectToPythonObject(gp.TableToTable_conversion(*gp_fixargs((in_rows, out_path, out_name, where_clause, field_mapping, config_keyword), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
The parameters for the TableToTable are not right. It is expecting an input table, the output path, and just the output table name. You have a full path (and string of a list "baseName") going into the table name parameter.
Set your code up in a loop to iterate over the list of tables you get and you can grab the name of each table for the output. Like Don mentioned, add some print statements or set some breakpoints and debug so you can see what your variables look like.
tables = arcpy.GetParameterAsText(0).split(';')
outpath = r"C:\UpdateDevelopmentPython\ForDeveloping\ForDeveloping.gdb"
for tble in tables:
baseName = os.path.basename(table)
#Create the standalone tables
TblResponseID = arcpy.TableToTable_conversion(tble, outpath, baseName)
Hi Jeff that worked great, thank yo so much!