1

I want to make a Feature Layer for each month in the table "Sightings1995-2014".

Why doesn't it work?

for month in range (01,12): arcpy.MakeFeatureLayer_management("Sightings1995-2014", "test%s" %month,"DATE >= date'01.%s.1995' AND DATE < date'01.%s.2014'" % (month, month+1)

Parsing error SyntaxError: invalid syntax (line 1)

for the output in each year this code worked

for year in range(1995,2014): arcpy.MakeFeatureLayer_management ("Sightings1995-2014", "test%s" % year, "DATE >= date'01.01.%s' AND DATE < date'01.01.%s'" % (year, year+1))

2
  • now python makes the FeatureLayer but does not put each month into a FeatureLayer. Instead he puts the hole "database" ("Sightings1995-2014") into each feature Layer -> so 12 Feature Layer with the hole database in it.
    – Lisa.J.
    Dec 17, 2014 at 10:08
  • Rather than tacking another question on as a comment I think you should research/ask it separately as per the Tour.
    – PolyGeo
    Dec 17, 2014 at 10:16

1 Answer 1

1

Try this:

for month in range (01,12):
    arcpy.MakeFeatureLayer_management("Sightings1995-2014", "test%s" %month,"DATE >= date'01.%s.1995' AND DATE < date'01.%s.2014'" % (month, month+1)

When you did it for year you ended your for statement with a colon (:), but when you did it for month that was omitted.

1
  • yeah that was the problem :D sometimes you didn't see mistakes like that.
    – Lisa.J.
    Dec 17, 2014 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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