Select to view content in your preferred language

Create Table Failing When Running Script Tool

581
2
Jump to solution
08-23-2023 06:37 PM
KeithMcDermott
New Contributor

Hi,

Very new to Python. I created a small script to compare data from two tables and create a third table containing the results of the comparison (a "results_table" that the user will define). It works when I run the code through my IDE, but when running the tool I receive the following error: 

ERROR 000354: The name contains invalid characters
Failed to execute (CreateTable).

Here is how I am defining the parameters: 

KeithMcDermott_0-1692840153206.png

Excerpts from the code:

import arcpy
arcpy.env.overwriteOutput=1

workspace = arcpy.GetParameterAsText(0)
arcpy.env.workspace = workspace

feature_class = arcpy.GetParameterAsText(1)
standards_table = arcpy.GetParameterAsText(2)
feature_id_field = arcpy.GetParameterAsText(3)
s_field = arcpy.GetParameterAsText(4)
results_table = arcpy.GetParameterAsText(5)

# CODE......
arcpy.management.CreateTable(workspace, results_table)

Any help would greatly appreciated. Thanks!!

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

CreateTable takes two arguments: The output workspace and the output name. Your last parameter is a Table, if you get that as text, it returns the table path. If you use that in CreateTable, it tries to create a table with the complete path as name. This puts illegal characters ("\") into the table name.

If you make the last parameter a String, it should work.


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

CreateTable takes two arguments: The output workspace and the output name. Your last parameter is a Table, if you get that as text, it returns the table path. If you use that in CreateTable, it tries to create a table with the complete path as name. This puts illegal characters ("\") into the table name.

If you make the last parameter a String, it should work.


Have a great day!
Johannes
KeithMcDermott
New Contributor

Making it a String parameter worked perfectly. Thanks, Johannes!

0 Kudos