Python/ArcPy遍历指定目录中的MDB文件

#遍历指定目录中的MDB文件,构造FeatureClass名
>>> target_folder = ‘D:\T20161202’
… file_names=(‘BOUAN’,’BOULK’,’BOUNT’,’BOUPT’,’CTRLK’,’CTRPT’,’HYDAN’,’HYDLK’,’HYDNT’,’HYDPT’,’PIPAN’,’PIPLK’,’PIPNT’,’PIPPT’,’RESAN’,’RESLK’,’RESNT’,’RESPT’,’ROAAN’,’ROALK’,’ROANT’,’ROAPT’,’TERAN’,’TERLK’,’TERNT’,’TERPT’,’VEGAN’,’VEGLK’,’VEGNT’,’VEGPT’)
… source_folder = ‘C:\Users\lenovo\Desktop\modified’
… for x in os.listdir(source_folder):
…     file_path = source_folder+’\\’+x
…     if os.path.isfile(file_path):
…         print file_path
…         mdb_paths= os.path.split(file_path)
…         mdb_names = mdb_paths[1].split(‘.’)
…         if mdb_names[-1]==’mdb’:
…             for file_name in file_names:
…                 feature_class = os.path.join( file_path,file_name)
…                 print feature_class
…                 
C:\Users\lenovo\Desktop\modified\74754025.mdb
C:\Users\lenovo\Desktop\modified\74754025.mdb\BOUAN
C:\Users\lenovo\Desktop\modified\74754025.mdb\BOULK
C:\Users\lenovo\Desktop\modified\74754025.mdb\BOUNT
C:\Users\lenovo\Desktop\modified\74754025.mdb\BOUPT
C:\Users\lenovo\Desktop\modified\74754025.mdb\CTRLK
C:\Users\lenovo\Desktop\modified\74754025.mdb\CTRPT
C:\Users\lenovo\Desktop\modified\74754025.mdb\HYDAN
C:\Users\lenovo\Desktop\modified\74754025.mdb\HYDLK

转载自:https://blog.csdn.net/a_dev/article/details/54344277

You may also like...