<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic List has invalid syntax error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014864#M59445</link>
    <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I am getting an error from a list from a csv that I want to use to loop through features in SDE.&lt;/P&gt;&lt;P&gt;It was working, but is throwing an error now??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;envarp_list = ["AirQualityReceptors_Ply", "AirQualityReceptors_Pt", "LandscapeCharacterAreas_Ply", "Viewpoints_Pt","LV_ZTV_Ply", "AssessmentLocationsAll_Pt"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;envarp_list = ["AirQualityReceptors_Ply", "AirQualityReceptors_Pt", "LandscapeCharacterAreas_Ply", "Viewpoints_Pt","LV_ZTV_Ply", "AssessmentLocationsAll_Pt"]
 
print("LOOP")
fcs = arcpy.ListFeatureClasses("server.gis.*")
for fc in fcs:
    for envarp in arcpror1_list:
        if fc == envarp:
            print(fc)
               print(new_name)
               arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, new_name)
        else:
            print("NOT in list")
            

print("END")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The list is much longer, it would be good to read directly from the csv file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error message is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SyntaxError                               Traceback (most recent call last)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ast.py, in parse:
Line 35:    return compile(source, filename, mode, PyCF_ONLY_AST)

SyntaxError: invalid syntax (&amp;lt;string&amp;gt;, line 29)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was working earlier with a smaller list, really need to read it from the csv, without looping 4 times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2021 21:45:07 GMT</pubDate>
    <dc:creator>CliveSwan</dc:creator>
    <dc:date>2021-01-07T21:45:07Z</dc:date>
    <item>
      <title>List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014864#M59445</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I am getting an error from a list from a csv that I want to use to loop through features in SDE.&lt;/P&gt;&lt;P&gt;It was working, but is throwing an error now??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;envarp_list = ["AirQualityReceptors_Ply", "AirQualityReceptors_Pt", "LandscapeCharacterAreas_Ply", "Viewpoints_Pt","LV_ZTV_Ply", "AssessmentLocationsAll_Pt"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;envarp_list = ["AirQualityReceptors_Ply", "AirQualityReceptors_Pt", "LandscapeCharacterAreas_Ply", "Viewpoints_Pt","LV_ZTV_Ply", "AssessmentLocationsAll_Pt"]
 
print("LOOP")
fcs = arcpy.ListFeatureClasses("server.gis.*")
for fc in fcs:
    for envarp in arcpror1_list:
        if fc == envarp:
            print(fc)
               print(new_name)
               arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, new_name)
        else:
            print("NOT in list")
            

print("END")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The list is much longer, it would be good to read directly from the csv file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error message is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SyntaxError                               Traceback (most recent call last)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ast.py, in parse:
Line 35:    return compile(source, filename, mode, PyCF_ONLY_AST)

SyntaxError: invalid syntax (&amp;lt;string&amp;gt;, line 29)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was working earlier with a smaller list, really need to read it from the csv, without looping 4 times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014864#M59445</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2021-01-07T21:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014867#M59446</link>
      <description>&lt;P&gt;envarp_list&lt;/P&gt;&lt;P&gt;is only used once in the code where is&lt;/P&gt;&lt;P&gt;arcpror1_list&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:44:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014867#M59446</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-07T21:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014869#M59447</link>
      <description>&lt;P&gt;I see you do have an extra indent in the two lines under&amp;nbsp;&lt;FONT face="courier new,courier"&gt;print(fc)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:49:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014869#M59447</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-01-07T21:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014880#M59448</link>
      <description>&lt;P&gt;That should have flagged a syntax error as well.&amp;nbsp; I wonder if there is no linting and code checking going on.&amp;nbsp; Where is this being run?&lt;/P&gt;&lt;P&gt;The python thing in Pro?&lt;/P&gt;&lt;P&gt;A separate python IDE?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:05:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014880#M59448</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-07T22:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014910#M59452</link>
      <description>&lt;P&gt;It is running but not returning the csv??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;f = open("W:\My Documents\user\Priority List 1.csv")

envarp_list = csv.reader(f)
               
print("LOOP")
fcs = arcpy.ListFeatureClasses("server.gis.*")
for fc in fcs:
    new_name = fc.split(".")[-1]
    for envarp in envarp_list:
        if fc == envarp:
            print(fc)
            print(new_name)
            arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, new_name)
        else:
            print("NOT in list")
            

print("END")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just returns not in the file. There are thousands of Features and I want to export a subset to gdb???&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:53:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014910#M59452</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2021-01-07T22:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014914#M59453</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/9619"&gt;@CliveSwan&lt;/a&gt;&amp;nbsp;I can't even get past your first line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;f = "W:\My Documents\user\Priority List 1.csv"
  File "&amp;lt;ipython-input-3-dc6c4d32386f&amp;gt;", line 1
    f = "W:\My Documents\user\Priority List 1.csv"
       ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 15-16: truncated \uXXXX escape&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you using a python IDE like Spyder, pycharm, whatever ???&lt;/P&gt;&lt;P&gt;Syntax errors and code syntax issues aren't being flagged for you.&lt;/P&gt;&lt;P&gt;You need to raw encode your paths....&amp;nbsp;&lt;STRONG&gt; r&lt;/STRONG&gt;"W:\My Documents\user\Priority List 1.csv"&amp;nbsp; ... a little &lt;STRONG&gt;r&lt;/STRONG&gt; goes a long way&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AND&lt;/P&gt;&lt;P&gt;Throw multiple print statements into your code&lt;/P&gt;&lt;P&gt;If you are getting strings/text from files, like you are, you would be advised to use "strip" to remove leading trailing spaces...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;oops = "TestMe          "

test_against = ["TestMe", " TestMe", "TestMe "]
oops in test_against
False

[oops == i.strip() for i in test_against]
[False, False, False]

[oops.strip() == i.strip() for i in test_against]  # ****** bingo!!!
[True, True, True]&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Jan 2021 23:03:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014914#M59453</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-07T23:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014921#M59454</link>
      <description>&lt;P&gt;I am using Pycharm. That happens when spend 4 hours working on a problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not throwing any errors, doesn't seem to read the csv?? It didn't return a single Features.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 23:11:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014921#M59454</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2021-01-07T23:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014924#M59455</link>
      <description>&lt;P&gt;check the path... put in print statements to see if it is returning anything like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;envarp_list = csv.reader(f)
for i in envarp_list:
    print(i)&lt;/LI-CODE&gt;&lt;P&gt;then when you know there is stuff in there check for the leading trailing spaced AND is the case the same? (upper,&amp;nbsp; lower etc )&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 23:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1014924#M59455</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-07T23:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: List has invalid syntax error</title>
      <link>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1242883#M66319</link>
      <description>&lt;P&gt;Syntax errors&lt;BR /&gt;Make sure you are not using a Python keyword for a variable name.&lt;BR /&gt;Check that you have a colon at the end of the header of every compound statement, including for, while, if, and def statements.&lt;BR /&gt;Check that indentation is consistent.&amp;nbsp;&lt;BR /&gt;Make sure that any strings in the code have matching quotation marks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rachel Gomez&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 06:33:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-has-invalid-syntax-error/m-p/1242883#M66319</guid>
      <dc:creator>RachelGomez</dc:creator>
      <dc:date>2022-12-21T06:33:51Z</dc:date>
    </item>
  </channel>
</rss>

