2

One of my colleagues is running a script which includes the following Python in ArcMap...

oTble = arcpy.mapping.TableView(tbleName)
Workspace = oTble.workspacePath

print "oTble:  '{}'".format(oTble)
if not Workspace:
    print "NULL Workspace!"
    sys.exit()

print "WORKSPACE:  {}".format(Workspace)

...and it exits after producing the following output:

oTble:  '<geoprocessing Standalone Table object object at 0x2B734A88>'
NULL Workspace!

Another colleague runs the same script and it continues on without this problem.

I cannot figure out how a TableView cannot have a NULL workspacePath .

Any ideas how this could happen?

UPDATE 1:

I have created a new MXD, and added the table to this new MXD. It works fine there. If I delete ALL layers and tables from the original MXD, and then add the table back into the original MXD in the same way as I did for the new MXD, it still fails.

UPDATE 2:

Based on the suggestion in comments, I've added the following code for debugging purposes...

d = arcpy.Describe(oTble)
print d.baseName
print d.catalogPath

This outputs (actual values modified to protect the innocent):

SDE_DBName.GISADMIN
\SDE_DBName.GISADMIN.TableName

This does not include the workspace in it anywhere.

If I run the same on a new blank document after adding in the relevant table, I get:

SDE_DBName.GISADMIN.TableName
\\host\Connections\ConnectionFileName.sde\SDE_DBName.GISADMIN.TableName
4
  • 1
    The table will have no workspace path if the table is in arcpy.env.workspace Dec 6, 2017 at 2:08
  • It is not in arcpy.env.workspace. Dec 6, 2017 at 3:49
  • What is the value of tbleName? To open a table by name only it must be in the environ workspace, unless the table type does not support IWorkspace. Try d = arcpy.Describe(oTble) then Workspace = d.catalogPath[:len(d.baseName)-1] and see if that helps. Dec 6, 2017 at 5:16
  • Thanks for the advice @Michael. See update 2, above. Dec 7, 2017 at 22:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.