<?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 Re: Batch Re-projection script syntax error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284942#M21999</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks this was a valid error. But even after I correct it nothing changes. Still Pythonwin tells me invalid syntax and arcmap doesnt do anything after running the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Jan 2015 13:09:01 GMT</pubDate>
    <dc:creator>SalmanAhmed</dc:creator>
    <dc:date>2015-01-23T13:09:01Z</dc:date>
    <item>
      <title>Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284931#M21988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have started learning Python for ArcGIS last week and have a simple script to reproject all the datasets in a folder. The script says "syntax error- invalid syntax" but I can't find anything. Can someone please have a look? It seems something very basic but I'm pretty new so I don't see it at the moment. Also running this in ArcGIS prints "failed" right away. And the files are in place in the right folders. I have already checked.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;... sourceWorkspace = "C:\\Users\\tx8p90\\Desktop\\Lesson2"&lt;/P&gt;&lt;P&gt;... targetProjection = "C:\\Users\\tx8p90\\Desktop\\python excercise data\\Lesson1\\contourlines.shp"&lt;/P&gt;&lt;P&gt;... listDataSet = arcpy.ListDatasets(sourceWorkspace)&lt;/P&gt;&lt;P&gt;... try:&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for x in listDataset:&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputDataset = sourceWorkspace + "\\projected_" + x&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(x, outputDataset, targetProjection)&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Reprojection successful"&lt;/P&gt;&lt;P&gt;... except:&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "failed"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 18:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284931#M21988</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-21T18:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284932#M21989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HiSalman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, Try setting your workspace&amp;nbsp; before using the arcpy.ListDatasets()&lt;/P&gt;&lt;P&gt;eg,&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = sourceWorkspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, use the correct&amp;nbsp; arcpy.ListDatasets() arguements (wild card naming and feature type&lt;/P&gt;&lt;P&gt;eg,&lt;/P&gt;&lt;P&gt;listDataSet = arcpy.ListDatasets(wild_card = "*", feature_type = "Feature")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 19:03:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284932#M21989</guid>
      <dc:creator>SusanJones</dc:creator>
      <dc:date>2015-01-21T19:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284933#M21990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually tried setting up the workspace already although I think its not necessary as long as you give a path in the ListDataset() function. Anyways even doing that hasn't made any difference. I get the same syntax error. &lt;/P&gt;&lt;P&gt;Regarding the arguments, since I need to change projection for all the files in that folder irrespective of feature type, I don't need to set any arguments like starting letter or feature type. Is that not so?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Salman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 22:28:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284933#M21990</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-21T22:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284934#M21991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Salman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The arcpy.ListDataset() is calling for a wildcard.&lt;/P&gt;&lt;P&gt;Not sure if it is optional, but it wouldn't hurt to specifiy the wildcard ("*")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See if it works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Susan &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 22:33:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284934#M21991</guid>
      <dc:creator>SusanJones</dc:creator>
      <dc:date>2015-01-21T22:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284935#M21992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah! sorry I just realized I can't put a path in that function's argument. Ok but anyways the setting up workspace option is not working either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;import arcpy&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;... sourceWorkspace = "C:\\Users\\tx8p90\\Desktop\\Lesson2"&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;... targetProjection = "C:\\Users\\tx8p90\\Desktop\\python excercise data\\Lesson1\\contourlines.shp"&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;... arcpy.env.workspace = sourceWorkspace&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;... listDataSet = arcpy.ListDatasets()&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;... try:&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for x in listDataset:&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputDataset = sourceWorkspace + "\\projected_" + x&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(x, outputDataset, targetProjection)&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Reprojection successful"&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;... except:&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "failed"&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;&lt;/P&gt;&lt;P style="font-family: inherit; font-style: inherit; font-weight: inherit;"&gt;What could be the problem then?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 22:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284935#M21992</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-21T22:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284936#M21993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again&lt;/P&gt;&lt;P&gt;Also, I don't think arcpy.ListDataset() is expecting a workspace. &lt;/P&gt;&lt;P&gt;Perhaps, spectify the workspace before hand under the arcpy.env.workspace parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 22:36:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284936#M21993</guid>
      <dc:creator>SusanJones</dc:creator>
      <dc:date>2015-01-21T22:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284937#M21994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no luck still &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;IMG alt="error.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/53278_error.png" style="width: 620px; height: 262px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 22:48:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284937#M21994</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-21T22:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284938#M21995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Salman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please test the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tmpDir = "D:\\Tmp" ##tmpDir = r"d:\Tmp"&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = tmpDir&lt;/P&gt;&lt;P&gt;print arcpy.env.workspace&lt;/P&gt;&lt;P&gt;ld = arcpy.ListDatasets("*")&lt;/P&gt;&lt;P&gt;print ld&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is returned in the ld variable ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 22:55:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284938#M21995</guid>
      <dc:creator>SusanJones</dc:creator>
      <dc:date>2015-01-21T22:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284939#M21996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Salman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, What is the value of outputDataset? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, Output_Coordinate_System is expecting either a projection file (with a prj extension) or a coordinate system object. Not a shp extension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure the Shapefile has a projection, and then set the targetProjection to point to it's prj file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 23:01:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284939#M21996</guid>
      <dc:creator>SusanJones</dc:creator>
      <dc:date>2015-01-21T23:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284940#M21997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have two different cases for your dataset list: listDataSet and listDataset. These are two different things in Python.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 23:16:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284940#M21997</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-01-21T23:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284941#M21998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;D:\Tmp&lt;/P&gt;&lt;P&gt;None&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I get when I run your code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 13:07:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284941#M21998</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-23T13:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284942#M21999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks this was a valid error. But even after I correct it nothing changes. Still Pythonwin tells me invalid syntax and arcmap doesnt do anything after running the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 13:09:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284942#M21999</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-23T13:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284943#M22000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;replacing the shape file with the prj file doesn't change anything. Same syntax error. And I thought it was enough to just point to the shape file to get its projection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 13:10:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284943#M22000</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-23T13:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Re-projection script syntax error</title>
      <link>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284944#M22001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;Okay so I finally figured this out. It was a stupid mistake on my part. The files I had in the specified folders were actually feature classes and not datasets. Anyway it is not possible to create a dataset inside a folder. It can only be done inside a geodatabase. So for someone who knows their way around with ArcGIS, they could have noticed that I had just a folder in the code but I was calling &lt;/SPAN&gt;&lt;CODE style="padding: 1px 5px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: #222222; background-color: #eeeeee;"&gt;ListDataSets()&lt;/CODE&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;function which is wrong. Using &lt;/SPAN&gt;&lt;CODE style="padding: 1px 5px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: #222222; background-color: #eeeeee;"&gt;ListFeatureClasses()&lt;/CODE&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt; solved the issue and the files were properly reprojected. Thanks for all the inputs.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 20:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/batch-re-projection-script-syntax-error/m-p/284944#M22001</guid>
      <dc:creator>SalmanAhmed</dc:creator>
      <dc:date>2015-01-23T20:44:26Z</dc:date>
    </item>
  </channel>
</rss>

