I keep getting an error at line 22 of my code. It is telling me there is something wrong with my syntax. I have tried it a few different ways but have not been able to figure it out. Can anyone help?
On a peripheral note, you would be advised to locate your work in a shorter path structure since there are acceptable limits for certain data types and the error message returned has nothing to do with the length of the path, severely restricting one's ability to track down errors.
I see a couple of things. First, do not use closed parenthesis on line 20. Use indentation for the command. Since the command variables are in parenthesis, there is no need for a backslash. And line 22 syntax is incorrect.
arcpy<SPAN class="punctuation token">.</SPAN>Select_analysis<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Locations_lyr"</SPAN><SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"M:\NRD_Maps\etc"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'"Marker" = "'</SPAN> <SPAN class="operator token">+</SPAN> sitename <SPAN class="operator token">+</SPAN> <SPAN class="string token">'"'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Lines 23-25 and 28-29 should also use indentation.
Edit -
Perhaps line 22 should be like this:
<SPAN class="string token">'\'"Marker" = \\\''</SPAN> <SPAN class="operator token">+</SPAN> sitename <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\\\'\''</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
There is some discussion on this command here regarding the where clause.
Look at your line 20.
arcpy.Select_analysis("Locations_lyr"),\
Maybe you wanted to comment that out? The syntax in that line is incorrect.
BTW - to post python code, you can use the syntax highlighter and select python. when commenting, this is found in the ...More pulldown.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.