I have a script that lists all layers in an MXD and I have a script that lists all broken layers in an MXD. I want to list all layers, their name, source, description, and whether or not their source is broken. Can anyone help me with this?
import arcpy, os, fnmatch, csv
#Create an empty list of ArcMap documents to process...
mxd_list=["A.mxd", "B.mxd", "C.mxd"]
for mxd in mxd_list:
mxd = arcpy.mapping.MapDocument(mxd)
mapPath = mxd.filePath
fileName = os.path.basename(mapPath)
layers = arcpy.mapping.ListLayers(mxd)
filepath = "C:/Users/USERNAME/Desktop/"+ fileName[:-4]+".csv"
writer = csv.writer(file(filepath, 'wb'))
sourcelist = []
for layer in layers:
if layer.supports("dataSource"):
layerattributes = [layer.longName, layer.dataSource]
#Write the attributes to the csv file...
writer.writerow(layerattributes)
writer.writerow(sourcelist)
del writer