<?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: Need help with invalid syntax in Python with picture to blob script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414963#M32674</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/85077"&gt;Mark Senne&lt;/A&gt;‌ could you format your code to provide proper indentation and line numbers&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Sep 2020 16:24:58 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2020-09-03T16:24:58Z</dc:date>
    <item>
      <title>Need help with invalid syntax in Python with picture to blob script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414962#M32673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey everyone,&lt;/P&gt;&lt;P&gt;I am trying to edit an older script where pictures are placed in a folder from a collector map with picture attachments, it's been about a year since we have had to run this script and we are running into an error that says "Invalid syntax" on our arcpy.da.searchcursor function. This parcticular script is also supposed to place watermarks on our photos but we can't get it to work.&lt;/P&gt;&lt;P&gt;Here is the full code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Import the needed modules&lt;BR /&gt;import arcpy,os,sys&lt;/P&gt;&lt;P&gt;#Directory where files will be saved&lt;BR /&gt;#********Change to desired location and leave off the last backslash***********&lt;BR /&gt;saveDir = r'X:\TVA\NorthDeSoto\Deliverables\PicsWatermarked'&lt;/P&gt;&lt;P&gt;#Specify Table &amp;amp; FC&lt;BR /&gt;featureTable = r'X:\TVA\NorthDeSoto\Features\TVA_NorthDeSotoPoints20200902.gdb\Points__ATTACH'&lt;BR /&gt;featureClass = r'X:\TVA\NorthDeSoto\Features\TVA_NorthDeSotoPoints20200902.gdb\Points'&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;count=0&lt;BR /&gt;#Loop through rows&lt;BR /&gt;with arcpy.da.SearchCursor(featureTable,["REL_GLOBALID","DATA","ATT_NAME"]) as cursor:&lt;BR /&gt; for row in cursor:&lt;BR /&gt; flag=0&lt;BR /&gt; fileCount=2&lt;BR /&gt; wellName=""&lt;BR /&gt; #Replace second field with the field you want the files named (to LocID)&lt;BR /&gt; with arcpy.da.SearchCursor(featureClass,["GlobalID","FeatureID"]) as cursor2:&lt;BR /&gt; for row2 in cursor2:&lt;BR /&gt; if row2[0]==row[0]:&lt;BR /&gt; wellName = str(row2[1])&lt;BR /&gt; &lt;BR /&gt; finalName = ""&lt;BR /&gt; if wellName==None or wellName=="":&lt;BR /&gt; ##################################&lt;BR /&gt; ###################################&lt;BR /&gt; ###Change to zero if you want all pictures&lt;BR /&gt; ###################################&lt;BR /&gt; ###################################&lt;BR /&gt; flag=0&lt;BR /&gt; if wellName !=None:&lt;BR /&gt; wellName = wellName.replace("/","_").replace(".0","")&lt;BR /&gt; if os.path.exists(os.path.join(saveDir,wellName+'.jpg')):&lt;BR /&gt; while os.path.exists(os.path.join(saveDir,wellName+'.jpg')):&lt;BR /&gt; if os.path.exists(os.path.join(saveDir,wellName+'_'+str(fileCount)+'.jpg')):&lt;BR /&gt; fileCount = fileCount+1&lt;BR /&gt; else:&lt;BR /&gt; finalName = wellName+'_'+str(fileCount)&lt;BR /&gt; break&lt;BR /&gt; else:&lt;BR /&gt; finalName=wellName&lt;/P&gt;&lt;P&gt;if flag==0:&lt;BR /&gt; #Replace first field with the word you want in front of photo name&lt;BR /&gt; image = open(os.path.join(saveDir,"Pic_"+finalName+"_"+row[2].replace('.jpg','')+'.jpg'),'wb')&lt;BR /&gt; print finalName &lt;BR /&gt; image.write(row[1].tobytes())&lt;BR /&gt; image.close()&lt;BR /&gt; del image&lt;BR /&gt; count=count+1&lt;BR /&gt; print count&lt;BR /&gt; del wellName,finalName&lt;BR /&gt; #sys.exit()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#SDG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also attached a jpg of where the error occurs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2020 16:14:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414962#M32673</guid>
      <dc:creator>MarkSenne</dc:creator>
      <dc:date>2020-09-03T16:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with invalid syntax in Python with picture to blob script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414963#M32674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/85077"&gt;Mark Senne&lt;/A&gt;‌ could you format your code to provide proper indentation and line numbers&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2020 16:24:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414963#M32674</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-09-03T16:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with invalid syntax in Python with picture to blob script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414964#M32675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, I have updated the original question with the actual Python script as an attachment&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2020 16:30:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414964#M32675</guid>
      <dc:creator>MarkSenne</dc:creator>
      <dc:date>2020-09-03T16:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with invalid syntax in Python with picture to blob script</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414965#M32676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, for starters Line #18, arcpu ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of the attached script, what line exactly is giving the error and what is the error and traceback?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2020 23:02:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-invalid-syntax-in-python-with/m-p/414965#M32676</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-09-03T23:02:55Z</dc:date>
    </item>
  </channel>
</rss>

