<?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: Detecting Corrupt MXDs in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760723#M58672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good point Michael.&amp;nbsp; &lt;A href="https://community.esri.com/migrated-users/8066"&gt;Michael Volz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As we've had a couple of issues like this as well, we tend to use this method a lot now for each operation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14138482978248918" jivemacro_uid="_14138482978248918"&gt;
&lt;P&gt;with open(path + 'Log_' + Date + '.log', 'a') as output: #open log file in append mode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output.write(logentry)&lt;/P&gt;
&lt;P&gt;output.close()&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although this slows down the process quite a bit, it's better to know exactly what happened and at what point rather than the script simply crashing and not flushing the output cache to file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Added code format style to snippet, for some reason it wouldn't let me choose this when wrote my reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Oct 2014 00:22:14 GMT</pubDate>
    <dc:creator>AndrewQuee</dc:creator>
    <dc:date>2014-10-20T00:22:14Z</dc:date>
    <item>
      <title>Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760711#M58660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script that loops through all the MXDs in folder and subfolders and writes details of the layers to a text file.&amp;nbsp; The script works quite well, unless an MXD is corrupt at which point it fails (which I can completely understand!).&amp;nbsp;&amp;nbsp; The corrupt MXD caused ArcGIS to crash when I tried to open the document in ArcMap and also when I attempted to preview it in ArcCatalog.&amp;nbsp; I am not sure if it can be done, however can anyone suggest a way to check the MXD before making an attempt to process it by the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 03:36:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760711#M58660</guid>
      <dc:creator>JanetRogers</dc:creator>
      <dc:date>2012-04-10T03:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760712#M58661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried putting a try/except in your code to catch the map documents that are causing you issues?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
.... in loop
[INDENT]try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = mapping.MapDocument(mxdPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #.... do something
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #write to file which map documents are incorrect[/INDENT]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The try/except pattern should allow you to ignore the errors and output the failing paths to a text file or something else.&amp;nbsp; You can then take that file and run the mxd doctor on them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760712#M58661</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-12T08:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760713#M58662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your suggestion.&amp;nbsp; I am already using Try... Except, however the whole thing crashes before it gets to the exception handler.&amp;nbsp; I don't think it is possible to get around this - just wondered if there was some way of looking at a whole MXD to see if it is corrupt without actually going into it. Sort of like some Excel functions such as ISNA.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 00:08:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760713#M58662</guid>
      <dc:creator>JanetRogers</dc:creator>
      <dc:date>2012-04-11T00:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760714#M58663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Do you know where it's crashing?&amp;nbsp; Are you sure it's related to arcpy/a bad map document?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you post a sample of your code and a good and bad map document?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 09:07:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760714#M58663</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2012-04-11T09:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760715#M58664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I apologise for taking so long to reply.&amp;nbsp; Been so busy I haven't been able to get back to this script.&amp;nbsp; I deleted the MXD that caused the problem, as it couldn't be opened either so I can't get post it here.&amp;nbsp; When I get a moment free I will see if I can replicate the problem somewhere else.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll attach the code so far.&amp;nbsp; (Realised I need to check for broken data sources before I write out the layer details, so coding is still not complete).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 02:11:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760715#M58664</guid>
      <dc:creator>JanetRogers</dc:creator>
      <dc:date>2012-04-27T02:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760716#M58665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Janet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have had to perform this task in older versions of ArcMap as well where python did not have its current capabilities so VBA was used.&amp;nbsp; In each case, whether it be in python or VBA, a corrupt mxd always crashed the script even with error handling such as try...except was used.&amp;nbsp; I have spoken with ESRI Technical representatives and they have confirmed that there is no way around a corrupt mxd in VBA or python scripting except to exclude it all together from your loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case, I had a script that would take an inventory of all mxds and various connections such as SDE.&amp;nbsp; This was a read-only step where information was saved to an output text file.&amp;nbsp; When the script would crash on a corrupt mxd, it would be noted and added to the code for the other script, that modified paths to data, so that script would just bypass these corrupt files and hopefully never crash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this information helps you to come up with a solution.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 17:10:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760716#M58665</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-04-27T17:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760717#M58666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks mvolz47.&amp;nbsp; I haven't solved this problems (as you said, I don't think this is possible) however it has enabled me to add some extra logging of the MXD names right at the beginning of the loop.&amp;nbsp; If the code fails, I now know which document is causing the problem and can eliminate it from&amp;nbsp; the folder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Janet&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2012 03:49:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760717#M58666</guid>
      <dc:creator>JanetRogers</dc:creator>
      <dc:date>2012-05-01T03:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760718#M58667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Janet:&lt;BR /&gt;&lt;BR /&gt;I have had to perform this task in older versions of ArcMap as well where python did not have its current capabilities so VBA was used.&amp;nbsp; In each case, whether it be in python or VBA, a corrupt mxd always crashed the script even with error handling such as try...except was used.&amp;nbsp; I have spoken with ESRI Technical representatives and they have confirmed that there is no way around a corrupt mxd in VBA or python scripting except to exclude it all together from your loop.&lt;BR /&gt;&lt;BR /&gt;In my case, I had a script that would take an inventory of all mxds and various connections such as SDE.&amp;nbsp; This was a read-only step where information was saved to an output text file.&amp;nbsp; When the script would crash on a corrupt mxd, it would be noted and added to the code for the other script, that modified paths to data, so that script would just bypass these corrupt files and hopefully never crash.&lt;BR /&gt;&lt;BR /&gt;I hope this information helps you to come up with a solution.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;While doing the same type of mxd listing work I have found that arcpy has no problems in dealing with corrupt mxds when run from an ArcCatalog/ArcMap python command line.&amp;nbsp; However the same command run from a regular python window, IDLE or Pythonwin will cause python to crash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;map_doc = arcpy.mapping.MapDocument('path_to_mxd')
data_frames = arcpy.mapping.ListDataFrames(map_doc)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;For a corrupt mxd, this code crashes in stand alone python but runs in the ArcCatalog/Map python window.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:19:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760718#M58667</guid>
      <dc:creator>David_JAnderson</dc:creator>
      <dc:date>2021-12-12T08:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760719#M58668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, that is very useful information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Janet&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Oct 2013 06:28:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760719#M58668</guid>
      <dc:creator>JanetRogers</dc:creator>
      <dc:date>2013-10-17T06:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760720#M58669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you share how you noted when an mxd was corrupt?&amp;nbsp; I'm also working on a program that walks through mxds in a folder to determine if a particular layer is used or not and writes it to a csv file but the script crashes when it encounters a corrupt mxd.&amp;nbsp; But it crashes before the list is written to the csv file so I never know which one it is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any guidance would be great &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 00:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760720#M58669</guid>
      <dc:creator>KariBuckvold</dc:creator>
      <dc:date>2014-10-15T00:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760721#M58670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We had a similar issue (and needed what sounds like the same script) relating to ArcGIS suddenly not liking shapefiles/rasters on a network drive, with the MXD/layers file crashing ArcMap/ArcCatalog instantly as soon as you tried to open them.&amp;nbsp; This happened across multiple installations and versions, all on the one day, and has actually occurred twice now.&amp;nbsp; It seemed as though ArcMap was corrupting something as it was writing to the document; possibly as a result of some network issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Crazily enough, the document was recoverable, by disconnecting the network adaptor or data source drive, then re-saving it - the new document worked absolutely fine, didn't even need to repair data connections.&amp;nbsp; Disabling the data source also allowed the following script to work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14133364143907870" jivemacro_uid="_14133364143907870" modifiedtitle="true"&gt;
&lt;P&gt;#-------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;# Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExportMXDLayers.py&lt;/P&gt;
&lt;P&gt;#&lt;/P&gt;
&lt;P&gt;# Purpose:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List the layers of a specified mxd and attempt to save layer&lt;/P&gt;
&lt;P&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; files from the layers in that mxd&lt;/P&gt;
&lt;P&gt;#&lt;/P&gt;
&lt;P&gt;# Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Peter von Minden and Julian Ward&lt;/P&gt;
&lt;P&gt;# Edited:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Andrew Quee&lt;/P&gt;
&lt;P&gt;#&lt;/P&gt;
&lt;P&gt;# Created:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22/08/2013&lt;/P&gt;
&lt;P&gt;# Edited:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16/12/2013&lt;/P&gt;
&lt;P&gt;#-------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;errSummary = ""&lt;/P&gt;
&lt;P&gt;succSummary = ""&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Must have a valid path to to the mxd in question using double backslashes "\\"&lt;/P&gt;
&lt;P&gt;mxd = arcpy.mapping.MapDocument("D:\\Temp\\Export.mxd")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;print "\nLAYER_NAME,DATA_SOURCE"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for lyr in arcpy.mapping.ListLayers(mxd):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name + "," + lyr.dataSource&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Must have a valid folder to dump the .lyr files using double&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # backslashes "\\"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SaveToLayerFile_management(lyr, "D:\\Temp\\" + lyr.name + ".lyr", "ABSOLUTE")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; succSummary += "Sucessfully Created " + lyr.name + ".lyr\n"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; errSummary += "Failed Creating " + lyr.name + ".lyr\n"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;print "\n****SUMMARY FOR LAYER FILE CREATION****\n\n****SUCCESFUL****\n\n" + succSummary + "\n****ERRORS****\n\n" + errSummary&lt;/P&gt;
&lt;P&gt;wait = raw_input("Press ENTER to continue")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;(Sorry if it's a bit rough, it was literally hacked together in a few minutes while users were screaming about 'nothing working' to recreate their broken MXDs)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coming back to the question, I'm not sure this is possible, David's tip aside.&amp;nbsp; In our experience, as soon as any Esri application touches a corrupted MXD, bang "ArcGIS Desktop has encountered a serious application error and is unable to continue."&amp;nbsp; This also applies to ArcPy, as you've found.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 01:32:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760721#M58670</guid>
      <dc:creator>AndrewQuee</dc:creator>
      <dc:date>2014-10-15T01:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760722#M58671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kari:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although this adds another step to your process, I would run through the files that you plan to process without actually resourcing your data and log the files that you have read through.&amp;nbsp; If the script crashes, you know it is the next file in the directory so you can exclude that file by name (or delete it entirely if you find it totally corrupted).&amp;nbsp; I would perform this process by subfolders of your main folder so if the script crashes on a corrupt mxd you don't need to go through as many files in your next run.&amp;nbsp; This was an important step in resourcing my organization's mxds and lyr files which numbered in the 10s of thousands and had 100s of thousands of data connections that needed to be resourced.&amp;nbsp; I hope this information helps you through this tedious but important process to your endusers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 12:34:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760722#M58671</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2014-10-15T12:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760723#M58672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good point Michael.&amp;nbsp; &lt;A href="https://community.esri.com/migrated-users/8066"&gt;Michael Volz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As we've had a couple of issues like this as well, we tend to use this method a lot now for each operation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14138482978248918" jivemacro_uid="_14138482978248918"&gt;
&lt;P&gt;with open(path + 'Log_' + Date + '.log', 'a') as output: #open log file in append mode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output.write(logentry)&lt;/P&gt;
&lt;P&gt;output.close()&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although this slows down the process quite a bit, it's better to know exactly what happened and at what point rather than the script simply crashing and not flushing the output cache to file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Added code format style to snippet, for some reason it wouldn't let me choose this when wrote my reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Oct 2014 00:22:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760723#M58672</guid>
      <dc:creator>AndrewQuee</dc:creator>
      <dc:date>2014-10-20T00:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Corrupt MXDs in Python</title>
      <link>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760724#M58673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"append" was the key I was missing!&amp;nbsp; Thanks, it's always the little things!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Oct 2014 19:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/detecting-corrupt-mxds-in-python/m-p/760724#M58673</guid>
      <dc:creator>KariannBuckvold</dc:creator>
      <dc:date>2014-10-20T19:25:55Z</dc:date>
    </item>
  </channel>
</rss>

