0

I have shapefiles in that form

RCs4s3s2c10_S2C10
RCs4s3s2c20_S2C20
RCs4s3s2c30_S2C30
RCs4s3s2c40_S2C40
RCs4s3s2c50_S2C50
RCs4s3s2c60_S2C60
RCs4s3s2cb_S2CB
RCs4s3s2c10_1_S2C10
RCs4s3s2c20_1_S2C20
RCs4s3s2c30_1_S2C30
RCs4s3s2c40_1_S2C40
RCs4s3s2c50_1_S2C50
RCs4s3s2c60_1_S2C60
RCs4s3s2cb_1_S2CB
RCs4s3s2c10_2_S2C10
RCs4s3s2c10_2_S2C10
RCs4s3s2c20_2_S2C20
RCs4s3s2c30_2_S2C30
RCs4s3s2c40_2_S2C40
RCs4s3s2c50_2_S2C50
RCs4s3s2c60_2_S2C60
RCs4s3s2c10_2_S2C10
RCs4s3s2cb_2_S2CB

How can i use a second wildcard parameter in my code for the first group of fc which don't have a number between _ cause with the following code

featureclasses = arcpy.ListFeatureClasses("RCs*", "Polyline", "")
    for fc in featureclasses:
          ....

i get everything but i want only the first group of feature classes

closed as off-topic by PolyGeo May 30 '15 at 5:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here unless they relate directly to Geographical Information Systems, but they can be asked on Stack Overflow." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Note that you can only use one wildcard with each issuance of arcpy.ListFeatureClasses() but once you have the Python list returned it can be manipulated with any applicable Python function(s). If you need to learn more about those Python (rather than ArcPy) functions I recommend consulting Stack Overflow. – PolyGeo May 30 '15 at 4:05
  • @PolyGeo i am interested how can i manipulate this pattern of shapefile names cause i work in Python Window in ArcGis 10.2. I think i can use something like case = [....], for fc in arcpy.ListFeatureClasses(): for case in cases: if fc.startswith(case):, but after that i don't know if i can use an UpdateCursor – por.bet May 30 '15 at 4:20
  • Once you have a Python list, and there is nothing special about the Python list returned by arcpy.ListFeatureClasses(), you will only need to use pure Python (better researched at Stack Overflow) functions for further manipulation to filter out any remaining unwanted strings. – PolyGeo May 30 '15 at 4:25
  • As a little Python tutorial try something like featureclasses = ["RCs4s3s2c10_S2C10","RCs4s3s2c10_1_S2C10","RCs4s3s2cb_2_S2CB"] for fc in featureclasses: if "_1_" in fc: print fc This will work exactly the same in ArcMap's Python window as it does in IDLE or any other Python IDE – PolyGeo May 30 '15 at 4:32
  • but if i try what you are saying i will take back only RCs4s3s2c10_1_S2C10 and nothing else? – por.bet May 30 '15 at 4:38
1

Please note that this answer (and hence your question) is pure Python:

# Make a list object - this can be done using arcpy.ListFeatureClasses or any other means
featureclasses = ["RCs4s3s2c10_S2C10","RCs4s3s2c10_1_S2C10","RCs4s3s2cb_2_S2CB","Test_X"]

# Make a new empty list
filteredFCs = []
# Iterate the original list
for fc in featureclasses:
    # Test each value to see if it meets the filtering criteria
    if "_1_" not in fc and "_2_" not in fc:
        # If it does then append it onto the filtered list
        filteredFCs.append(fc)

# Print out the filtered list
print filteredFCs

This is just one of many possible Python solutions to your question.

Pure Python questions are best researched/asked at Stack Overflow.

  • you are right this is one, i found one more thank you very much. – por.bet May 30 '15 at 7:47
  • cases = ['RCs4s3s2c10_S', 'RCs4s3s2c20_S', 'RCs4s3s2c30_S', 'RCs4s3s2c40_S', 'RCs4s3s2c50_S', 'RCs4s3s2c60_S', 'RCs4s3s2cb_S'] for fc in arcpy.ListFeatureClasses(): for case in cases: if fc.startswith(case): – por.bet May 30 '15 at 7:48

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