Good morning all,
I am new in Python and i need your help.
I have already wrote a program that works for one of the shapes that i need to check, but now i need to do the same for the rest of the shapes that i have in different folders.
How could i do it?
I really appreciate your help!
Flor
I am new in Python and i need your help.
I have already wrote a program that works for one of the shapes that i need to check, but now i need to do the same for the rest of the shapes that i have in different folders.
How could i do it?
I really appreciate your help!
Flor
Code:
#Import standard library modules
import arcgisscripting, sys, os, string
#Create the Geoprocessor object
gp= arcgisscripting.create(9.3)
#Set the input workspace
#gp.workspace=sys.argv[1]
gp.workspace = 'F:\\fiorenza\MPRGC25M\\77_21_Figueres'
#Set the output workspace
outWorkspace = 'F:\\fiorenza\MPRGC25M\\77_21_Figueres'
numfull = '77_21'
#try:
#Get a list of the featureclasses in the input folder
#fcs = gp.listfeatureclasses()
fcExisteix = []
poligon= ['suproc_7721.shp', 'bloc_diposits_7721.shp', 'areabloclliscament_7721.shp', 'esllavissades_7721.shp', 'altres_dip_7721.shp', 'cons_7721.shp', 'dibuixcons_7721.shp', 'limit_esf_7721.shp', 'indicis_7721.shp']
punts=['escpunt_772125M.shp', 'blc_ind_mes10_7721.shp', 'blc_ind_menys10_7721.shp', 'b_caiguts_ant_menys10_7721.shp', 'b_caiguts_ant_mes10_7721.shp', 'b_caiguts_rec_menys10_7721.shp', 'b_caiguts_rec_mes10_7721.shp', 'inven_dpr_7721.shp', 'bloclliscament_7721.shp', 'inventari_petits_7721.shp', 'ind_esf_7721.shp', 'antrExt_7721.shp','limit_esf_7721.shp', 'indicis_7721.shp']
arc= ['escarpaments_7721.shp', 'direccio_esllavissades_7721.shp','ind_esf_7721.shp', 'altresindicis_7721.shp', 'antrESc_7721.shp', 'eros_soscic_7721.shp']
## Get a list of the fields in the feature classes
escarpaments=['EscRoc11', 'EscRoc12', 'EscRoc13', 'EscRoc21', 'EscRoc22', 'EscRoc23', 'EscRoc31', 'EscRoc32', 'EscRoc33', 'EscSol11', 'EscSol12','EscSol13', 'EscSol21', 'EscSol22', 'EscSol23', 'EscSol31', 'EscSol32', 'EscSol33', 'LRtAnEsc', 'LRtRcEsc', 'LTrAnEsc', 'LTrRcEsc', 'MxtAnEsc', 'MxtRcEsc', 'FluxAnEsc', 'FluxRcEsc', 'ExpAnEsc', 'ExpRcEsc', 'CorrAnEsc', 'CorrRcEsc']
direccio_esllavissades=['LRtAnDirec', 'LRtRcDirec', 'LTrAnDirec', 'LTrRcDirec', 'MxtAnDirec','MxtRcDirec ', 'FluxAnDirec', 'FluxRcDirec', 'ExpAnDirec', 'ExpRcDirec', 'CorrAnDirec', 'CorrRcDirec']
ind_esf = ['EsfSubAnPt']
altresindicis = ['ErosSoscavAn', 'ErosSoscavRc', 'ErosEsc', 'ErosSOlc']
antrESc = ['AntrExtAbanEsc', 'AntrESc']
eros_soscic =['ErosSosCic']
suproc =['SupRoc1 ', 'SR1','SupRoc2 ', 'SR2', 'SupRoc3', 'SR3']
bloc_diposits=['BlcDispGran','BlcDispMitj','BlcDisppetit','BlcDipRc1','DB1r','BlcDipRc2','DB2r','BlcDipRc3', 'DB3r','BlcDipAn1','DB1a','BlcDipAn2','DB2a','BlcDipAn3','DB3a']
areabloclliscament=['AreaBlocllis']
esllavissades=['LRtAnLimit','LRtRcLimit','LTrAnLimit','LTrRcLimit','MxtAnLimit','Mxa','MxtRcLimit','Mxr','FluxAnLimit','FluxRcLimit','ExpAnLimit','ExpRcLimit','CorrAnLimit','CorrRcLimit']
altres_dip= ['ConDipIn','ConAltresAn','ConAltresRc']
cons=['ConDejAn']
limit_esf=['Doi','Doip','Kp','Ks']
indicis=['ConDipln','ErosInt','Ein','ErosMOd','Emd']
escpunt_codifull25M=['EscRocPetit','ERP']
blc_ind_mes10= ['BlcInd1Roc1MG','BlcIndRoc2G','BlcInd1Sol1MG','BlcIndSol2G']
blc_ind_menys10=['BlcIndRoc3M', 'BlcIndSol3M']
b_caiguts_ant_menys10=['BlcAn3Mitja','BlcAn4Petit']
b_caiguts_ant_mes10=['BlcAn1MGran','BlcAn2Gran']
b_caiguts_rec_menys10=['BlcRC3Miitja','BlcRC4Petit']
b_caiguts_rec_mes10=['BlcRC1MGran','BlcRC2Gran']
inven_dpr=['DprAnPetit','DprRcPetit','DpsAnPetit','DpsRcPetit']
bloclliscament=['Blocllis']
inventari_petits=['LRtAnMitj','LRtRcMitj','LRtAnPet','LRtRcPet','LTrAnMitj','LTrRcMitj','LTrAnPet','LTrRcPet','MxtAnMitj','MxtRctMitj','MxtAnPet','MxtRctPet','FluxAnMitj','FluxRcMitj','FluxAnPet','FluxRcPet','ExpAnMitj','ExpRcMitj','CorrAnMitj','CorrRcMitj','CorrAnPet','CorrRcPet']
ind_esf=['EsfCavAn','EsfCavRc']
antrExt=['AntrExtAban']
limit_esf=['Dsa','Dsp']
indicis=['BlcIndDisc','BlcIndBalm','BlcIndSost','BlcIndDesp','IndDef','IndEsqTerr','IndArbres','IndSurgen','IndSurgenTerm','IndAiguam','IndEsqEdif']
fclistpoly = gp.listfeatureclasses("*", "polygon")
fclistpunts = gp.listfeatureclasses("*", "point")
fclistarc = gp.listfeatureclasses("*", "arc")
fcNoExisteix =[]
fcExisteix =[]
outFeatureClass = []
nomarxiu = 'F:\\fiorenza\MPRGC25M\\workfile_' + numfull + '.txt'
print nomarxiu
f = open(nomarxiu,'w')
f.write('arcs_comprobats:\n\n')
for fc in arc:
fc1 = 0
arE=0
for fc1 in fclistarc :
outFeatureClass = outWorkspace + "\\" + fc
#fc1.lower
if str(fc) == str(fc1):
arE = 1
fcExisteix.append (fc1)
if arE == 1:
f.write(outFeatureClass + '......... existeix\n')
else:
fcNoExisteix.append(fc1)
f.write(outFeatureClass + '......... no existeix\n')
f.write('\npunts_comprobats:\n\n')
for fc in punts:
puE=0
for fc1 in fclistpunts :
outFeatureClass = outWorkspace + "\\" + fc
#fc1.lower
if str(fc) == str(fc1):
puE = 1
fcExisteix.append (fc1)
if puE == 1:
f.write(outFeatureClass + '......... existeix\n')
else:
fcNoExisteix.append(fc1)
f.write(outFeatureClass + '......... no existeix\n')
f.write('\npoligons_comprobats:\n\n')
for fc in poligon:
poE=0
for fc1 in fclistpoly :
outFeatureClass = outWorkspace + "\\" + fc
#fc1.lower
if str(fc) == str(fc1):
poE = 1
fcExisteix.append (fc1)
if poE == 1:
f.write(outFeatureClass + '......... existeix\n')
else:
fcNoExisteix.append(fc1)
f.write(outFeatureClass + '......... no existeix\n')
#Ara comencem a comprobar el camp codi_BD
fcCampNE=[]
f.write('\nComprobant el shape escarpaments.shp :\n\n')
for fc in fcExisteix:
registres = []
llista =[]
fields = gp.ListFields(fc)
#fields = gp.ListFields('escarpaments_7721.shp')
for field in fields:
if str(field.Name) == 'Codi_BD':
cur = gp.SearchCursor (fc)
row = cur.Next()
nn = 0
while row <> None:
llista.append(row.Codi_BD)
row = cur.Next()
for item in llista:
#Aqui crearem una nova llista eliminant duplicats
if item <>' ':
if item not in registres:
registres.append(item)
for valor_camp in registres:
treure = '_' + numfull + '.shp'
llistaValor = fc.lstrip(treure)
print llistaValor
for valorFila in llistaValor:
correcte = 0
if str(valor_camp) == str(valorFila):
correcte = 1
if correcte == 0:
# f.write(outFeatureClass+'-'+valor_camp + '......... existeix\n')
#else:
fcCampNE.append(valor_camp)
nn = nn + 1
for camp in fcCampNE:
print camp
f.write('\n'+ camp)
#f.write("\nHi ha " + str(nn) + " registres erronis.\n")
f.write('\nComprobats tots els fitxers')
f.close()
Comment