lavpizzo

Table to Geodatabase

Discussion created by lavpizzo on Jun 1, 2012
Latest reply on Jun 1, 2012 by fabl
Hello,

I am trying to import .txt files (tables) into a geodatabase (as a table) using the code below, but am getting the following error:

Traceback (most recent call last):
      inTables = inTables + " ; " + tb
TypeError: can only concatenate tuple (not "str") to tuple

Does anyone know what might be causing this and how to fix it?

Thank-you

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

# To import the .txt tables into the geodatabase
# the folder where the original table files are stored
inFolder = "C:\\w\\x\\y\\z\\mnth"
# the geodatabase where the tables will be imported to
outGeodatabase = "C:\\w\\x\\test.gdb"
inTables = ("*", "txt")

gp.Workspace = inFolder

tbs = gp.ListTables()
tb = tbs.Next()
while tb:
    if inTables:
        inTables = inTables + " ; " + tb
    else:
        inTables = tb
    tb = tbs.Next()

# Put a try-except-look around the tool, in case an error occurs
try:
    print "Importing the following tables: " + inTables
    gp.TableToGeodatabase(inTables, outGeodatabase)

except:
    # If an error occurred, print the messages returned by the tool
    print gp.GetMessages()

print "Completed: Table Added to Geodatabase"

Outcomes