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
1 Answer 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
Explore related questions
See similar questions with these tags.
lang-py