Listing Data sources using arcpy

المشرف العام

Administrator
طاقم الإدارة
What I am trying to do is create a list of all the data sources in a directory filled with mxds.So I have this code pasted below. For some reason when listing layers it can take up to 50 minutes even though the mxd only has around 10 or 15 layers. Is this a common occurrence with the listlayers method?

for layer in arcpy.mapping.ListLayers(mxd): print "boop" if layer.supports("DATASOURCE"): writer.writerow({'DATASOURCE' : layer.dataSource}) else: breakSo my issue with the above code is when I am running it It will take forever to get to the 'print "boop"'but once it gets there it runs perfectly fine. It seems to get hung up at the arcpy.mapping.ListLayers(mxd) for a very long time.

Sometimes its great, only takes a few seconds, other times 8 minutes. That is manageable, but when I leave my code running all night and some of them take 50 minutes or it just crashes, that is the problem (it crashed due to a memory error). These mxds do not have that many layers in them either.

There is usually just one data frame that has at the most 20 layers in them. I can open these mxds myself and it only takes a few minutes at the most when i do.



أكثر...
 
أعلى