使用python读取projectwise文件夹

时间:2019-04-02 15:32:07

标签: python python-2.7 projectwise

我正在尝试以projectwise方式链接到一个包含mxds的文件夹,我需要获取该文件夹中的要素类列表,但在python控制台中该目录不正确。但是直接在Windows中尝试路径是可行的,并且直接将我带到projectwise的文件夹中。我不确定是否没有在python中正确读取文件夹

import arcpy, os  
#this is the projectwise folder 
path = r"pw:\\up114.dataonline.local:PWM\Documents\60439-Stone Tech\300 Non Deliverables\Management Team\G\Fig"
#Update the .csv file name below(stored in the folder where python script is
 f = open('inventory.csv', 'w')  
 f.write("Title, Layer, Dataset Path" + "\n")  
for root, dirs, files in os.walk(path):  
    for fileName in files:  
        basename, extension = os.path.splitext(fileName)  
#Write the information for all .mxd's with broken data sources  
        if extension == ".mxd":  
            fullPath = os.path.join(root, fileName)  
            mxd = arcpy.mapping.MapDocument(fullPath)  
            Layers = arcpy.mapping.ListLayers(mxd)
            for Layer in Layers:
                if Layer.supports("DATASOURCE"):
                    if Layer.isFeatureLayer or Layer.isGroupLayer: 
                        print "Layer: " + Layer.name
                        f.write(fileName + ", "  + Layer.name + ", " + Layer.dataSource +  ","  "\n")  
                    else:
                        f.write("\n")


f.close()  

print 'Completed creating list'

0 个答案:

没有答案