<?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: Exporting arcGIS attachments using arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1251002#M66635</link>
    <description>&lt;P&gt;It's hard to tell without an example, but I think you might be opening the attachment without a file extension.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jan 2023 20:17:11 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2023-01-24T20:17:11Z</dc:date>
    <item>
      <title>Exporting arcGIS attachments using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1250944#M66629</link>
      <description>&lt;P&gt;I'm trying to export all attachments from an attachment table in a gdb to a folder. I'm using a script I found&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://support.esri.com/en/technical-article/000011912" target="_blank" rel="nofollow noopener noreferrer"&gt;here&lt;/A&gt;. I keep getting the error that item[0] is None and so has no attribute 'tobytes'. This table is a standard ATTACH table with the default fields. I appreciate any suggestions!&lt;/P&gt;&lt;P&gt;inTable = [path to ATTACH table] fileLocation = [Export folder]&lt;/P&gt;&lt;P&gt;for fc in list: print(fc)&lt;/P&gt;&lt;P&gt;with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID']) as cursor: for item in cursor: attachment = item[0] print(attachment) filenum = str(item[2]) + "_" print(filenum) filename = filenum + str(item[1]) print(filename) open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes()) del item del filenum del filename del attachment&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Traceback (most recent call last): File "C:\Users\gscmm\PycharmProjects\pythonProject2\AttachmentDownloader.py", line 33, in open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes()) AttributeError: 'NoneType' object has no attribute 'tobytes'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:04:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1250944#M66629</guid>
      <dc:creator>Chase_Mohrman</dc:creator>
      <dc:date>2023-01-24T19:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting arcGIS attachments using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1250976#M66632</link>
      <description>&lt;P&gt;To post code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1674589814049.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61109iE6E36886309482F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1674589814049.png" alt="JohannesLindner_0-1674589814049.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1674589827880.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61110i9AA607855960C6E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1674589827880.png" alt="JohannesLindner_1-1674589827880.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably have empty attachments. Try replacing the SearchCursor line with this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID'], 'DATA IS NOT NULL') as cursor:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:52:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1250976#M66632</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-01-24T19:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting arcGIS attachments using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1250982#M66633</link>
      <description>&lt;P&gt;You might get more responses if you format your code - it's very difficult to see what's going on as you've posted it. Here's some community guidelines for inserting code into a post:&amp;nbsp;&lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_blank"&gt;https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also might want to include other details like how are you running this code (python window, PyCharm, Toolbox, etc). Also, the output of your print statements would be useful. If this is the entire code it seems you haven't imported os. Also, did you append "_ATTACH" to the end of your table name? It's hard to help unless you supply all the details...&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 19:57:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1250982#M66633</guid>
      <dc:creator>ChrisRingo</dc:creator>
      <dc:date>2023-01-24T19:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting arcGIS attachments using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1251002#M66635</link>
      <description>&lt;P&gt;It's hard to tell without an example, but I think you might be opening the attachment without a file extension.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 20:17:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1251002#M66635</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-01-24T20:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting arcGIS attachments using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1251004#M66636</link>
      <description>&lt;P&gt;Thank you. For some reason, the very first attachment was empty. All I had to do was skip the first one and the rest import properly. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 20:22:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1251004#M66636</guid>
      <dc:creator>Chase_Mohrman</dc:creator>
      <dc:date>2023-01-24T20:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting arcGIS attachments using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1364506#M69488</link>
      <description>&lt;P&gt;Glad I found this post; the code you posted worked.&amp;nbsp; Looks like I have cleanup to do as well ... time to identify points without attachments.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 15:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-arcgis-attachments-using-arcpy/m-p/1364506#M69488</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2023-12-27T15:53:02Z</dc:date>
    </item>
  </channel>
</rss>

