0

I want to combine two FOR LOOPS but I have no idea how. It should give me in each TYPE Layer "under" Layers, where are new Layers for each MONTH (see picture)

enter image description here

The two loops in itself works.

# MakeFeatureLayer_management for each whale/dolphin type
whale_names = [
"Atlantic Spotted Dolphin",
"Pilot Whale",
"Bottlenose Dolphin",
"Rough-Toothed Dolphin",
"Bryde ́s Whale",
"Common Dolphin"]
 for name in whale_names:
 arcpy.MakeFeatureLayer_management("Sichtungen95-14", "test-" + name, "SPECIES = '%s'" % (name))
 # MakeFeatureLayer_management for each month
 for month in range (01,12): 
 arcpy.MakeFeatureLayer_management ("Sichtungen95-14", "test%s" % month, "DATE >= date'01.01.1995' AND DATE < date'01.01.2015' AND EXTRACT(MONTH FROM DATE) = %s" % (month))
gene
55.8k3 gold badges115 silver badges196 bronze badges
asked Jan 4, 2015 at 11:41

1 Answer 1

1

Simply indent your second for loop, and it will iterate the twelve months for each iteration of your initial loop.

for name in whale_names:
 arcpy.MakeFeatureLayer_management("Sichtungen95-14", "test-" + name, "SPECIES = '%s'" % (name))
 # MakeFeatureLayer_management for each month
 for month in range (01,12): 
 arcpy.MakeFeatureLayer_management ("Sichtungen95-14", "test%s" % month, "DATE >= date'01.01.1995' AND DATE < date'01.01.2015' AND EXTRACT(MONTH FROM DATE) = %s" % (month))
answered Jan 4, 2015 at 18:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.