コード例 #1
0
fen.title("FrequExcel")
shp = ficible(filetypes = [("Shapefiles","*.shp")])
for field in lister_champs(shp):
    liste_chps.append(field.name)
choix_champ = Pmw.ComboBox(fen, labelpos = NW,
                     label_text = "Choisir le champ : ",
                     scrolledlist_items = liste_chps,
                     listheight = 150,)
choix_champ.pack()
Button(fen, text="Calculer", command=valider).pack()
Button(fen, text="Annuler", command=annuler).pack()
fen.mainloop()

###### Calcul des fréquences
print "Calcul des fréquences"
rows = curs(shp, "", "", chp_cible, "")
for j in rows:
    if dico_occurences.has_key(j.getValue(chp_cible)):
        dico_occurences[j.getValue(chp_cible)] = dico_occurences.get(j.getValue(chp_cible))+1
    else:
        dico_occurences[j.getValue(chp_cible)] = 1

##### Création du fichier excel
print "Création et configuration du fichier excel"
book = xlwt.Workbook(encoding = 'Latin-1')
feuy1 = book.add_sheet('Frequences', cell_overwrite_ok=True)

font1 = xlwt.Font()             # création police 1
font1.name = 'Times New Roman'
font1.bold = True
entete = xlwt.XFStyle()         # création style pour les en-têtes
コード例 #2
0
ファイル: coding_mallas.py プロジェクト: Guts/ArcPy-stuffs
# Stats rapides
sel_attr(lyr, "CLEAR_SELECTION")

feuy1.write(0, 1, str(count_obj(lyr)))
j = 0
while j < 6:
    expression = "Tot_E = " + str(j)
    sel = sel_attr(lyr, "NEW_SELECTION", expression)
    feuy1.write(j + 1, 1, str(count_obj(sel)))
    print "Comptage du nombre d'objets selon " + expression
    j = j + 1


print "Calcul des fréquences"
rows = curs(mailles, "Tot_E > 0", "")
dixou = {}
for j in rows:
    if dixou.has_key(j.E_code):
        dixou[j.E_code] = dixou.get(j.E_code) + 1
    else:
        dixou[j.E_code] = 1

print "Inscription des fréquences dans le fichier excel"
x, y = 0, 0

for clef, valeur in dixou.items():
    feuy3.write(x + 1, y, clef)
    feuy3.write(x + 1, y + 1, valeur)
    x = x + 1