3

Python newbie needing help with a simple task. I'm trying to create a list of stand-alone tables in an sde workspace.

Code below works just fine to list feature class names and paths and table names.

fcList = gp.ListFeatureClasses()
for fc in fcList:
    descFC = gp.Describe(fc)
    print "FC Name: " + fc + ", Path: " + descFC.CatalogPath

tblList = gp.ListTables()
for table in tblList:
    print table

However, I am not able to use the Describe method to grab the tables' catalog path.

tblList = gp.ListTables()
for table in tblList:
    print table
    descTBL = gp.Describe(table)
    print descTBL.CatalogPath

I think my issue is in the gp.Describe line. What's wrong with gp.Describe(table)? From looking at code samples fc = feature class and fd = feature dataset. What abbreviation is used for table?

2
  • how does it not work? it errors (what error?), it prints nothing? it prints just the table name???
    – gotchula
    Feb 26, 2011 at 2:46
  • those are just naming conventions. what you're actually describing are variable names. You could call the table "Steve" or anything else. Do you get any other kind of responses? For instance, will it return debscTBL.Fields?
    – Luke
    Mar 23, 2011 at 17:31

1 Answer 1

1

I'm not sure what was wrong, must have been an error in a different section of the script. I appreciate your help. Final code below. It's nothing special except for the fact that it's my first working python script.

import arcgisscripting
gp = arcgisscripting.create(9.3)


Sewerage = "Database Connections\\Connection.sde\\"
gp.workspace = Sewerage

## open text file and define header row
csv_out = open ("C:\\My Documents\\Code\\ProductionServerList\\Sewerage.txt","a")
csv_out.write("type,name,path,count\n")

##Describe tables

tblList = gp.ListTables()

for table in tblList:
        descTBL = gp.Describe(table)
        count = gp.GetCount_management(table)
        csv_line = ("table," + table + "," + descTBL.CatalogPath + "," + count.GetOutput(0)+"\n")
        csv_out.write(csv_line)    

##Describe stand-alone feature classes

fcList = gp.ListFeatureClasses()

for fc in fcList:
        descFC = gp.Describe(fc)
        count = gp.GetCount_management(fc)
        csv_line = ("featureclass," + fc + "," + descFC.CatalogPath + "," + count.GetOutput(0)+"\n")
        csv_out.write(csv_line)

##Describe feature classes in feature datasets

fdList = gp.Listdatasets('','Feature')
for fd in fdList:
    gp.workspace = Sewerage + '\\' + fd
    newfcList = gp.ListFeatureClasses()
    for fc in newfcList:
        descFC = gp.Describe(fc)
        count = gp.GetCount_management(fc)
        csv_line = ("featureclass," + fc + "," + descFC.CatalogPath + "," + count.GetOutput(0)+"\n")
        csv_out.write(csv_line)
## close csv text file
csv_out.close()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.