Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
how does it not work? it errors (what error?), it prints nothing? it prints just the table name??? –  gotchula Feb 26 '11 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 '11 at 17:31

1 Answer 1

up vote 1 down vote accepted

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()
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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