daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Apr 17th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with open('data.csv', 'wb') as csvfile:
  2. fieldnames = ['File_Path', 'File_Size(MB)', 'Last_Edit', 'MXD_Version', 'Author', 'PageSize',
  3.               'XMAX', 'XMIN', 'YMAX', 'YMIN', 'DATASOURCE'] #all the header fields
  4. writer = csv.DictWriter(csvfile, fieldnames = fieldnames)
  5. writer.writeheader()
  6. for mapDocument in findFiles(r"W:/GIS (no purge)", '*.mxd'):
  7.     print mapDocument
  8.     st = os.stat(mapDocument)
  9.     print "Using ArcPY Mods..."
  10.     mxd = arcpy.mapping.MapDocument(mapDocument) #using arcpy to gather more information
  11.     print "Reading Map Document..."
  12.     writer.writerow({'File_Path' : str(mapDocument),
  13.                      'File_Size(MB)' : str(((st[ST_SIZE])/1024.0)/1024.0),
  14.                      'Last_Edit' : str(time.ctime(st[ST_MTIME])),
  15.                      'MXD_Version' : getMXDVersion(mapDocument)})
  16.  
  17.     print "Searching Layers and Writing..."
  18.     for layer in arcpy.mapping.ListLayers(mxd):
  19.         print "boop"
  20.         if layer.supports("DATASOURCE"):
  21.             writer.writerow({'DATASOURCE' : layer.dataSource})
  22.         else:
  23.             break
  24.     del mxd
  25.    
  26. for lyr in lyrList:
  27.             dType = "UNK"
  28.             dName = "UNK"
  29.             dPath = "UNK"
  30.             if lyr.supports("dataSource"):
  31.                 if lyr.supports("workspacePath"):
  32.                     dPath = lyr.workspacePath
  33.                 if lyr.supports("datasetName"):
  34.                     dName = lyr.datasetName
  35.                 try:
  36.                     dType = arcpy.Describe(lyr.dataSource).datasettype
  37.                 except:
  38.                     dType = "Possible broken link"
  39.             else:
  40.                 if lyr.isGroupLayer:
  41.                     dType = "Group Layer"
  42.                 if lyr.supports("SERVICEPROPERTIES"):
  43.                     arcpy.AddMessage('Found map survice')
  44.                     dType = lyr.serviceProperties["ServiceType"]
RAW Paste Data
Top