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.

I need to version n number of fc's which start with sde."ENT-QA". I need to select only those feature classes and run versioning for it. Can anyone help me in writing the query for selecting only fc's which start with sde."ENT-QA". Remeber ENT-QA is mentioned has quotes. Thanks in advance.

import arcpy
arcpy.env.workspace= r"xyz.sde"
fdList = arcpy.ListFeatureClasses("","","")

for fc in fdList:
    print fc
    arcpy.RegisterAsVersioned_management(fc, "NO_EDITS_TO_BASE")
    print "fc registered"
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Why not just use a wildcard with your ListFeatureClasses statement like:

fdList = arcpy.ListFeatureClasses("\"ENT-QA\"*","","")

as shown in Arc10 ListFeatureClasses online help?

UPDATE: code updated based upon nmpeterson's comments.

share|improve this answer
    
If you want to ensure that you're only selecting feature classes whose names contain "ENT-QA" and not ENT-QA (without the quotation marks), this would be fdList = arcpy.ListFeatureClasses("\"ENT-QA\"","","") –  nmpeterson Nov 15 '11 at 19:49
    
Nice catch. I overlooked the part about the value in quotes. Thanks for posting the correct syntax. I will update my response. –  RyanDalton Nov 15 '11 at 21:15
    
hi ryan, Id did not worked. –  Ramakrishna Billakanti Nov 15 '11 at 22:15
    
Try fdList = arcpy.ListFeatureClasses("\"ENT-QA\"*","",""). The asterisk should help. –  nmpeterson Nov 15 '11 at 22:21
    
Thanks Ryan for your comments, THis worked for me fcList = arcpy.ListFeatureClasses('sde."ENT-QA"*',"polygon","") –  Ramakrishna Billakanti Nov 16 '11 at 18:02

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.