1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| # Import system modules
import arcpy
import sys
from datetime import datetime, timedelta
inFeatures = r"\\srv-esriapp\connexion\sig_ev@srv-esribdd_dc.sde\sig.ev.ev_arbre_GBA"
fields = ['date_dia', 'delai_co', 'date_f_d']
# Retrieve the field values
data = []
with arcpy.da.UpdateCursor(inFeatures, fields) as cursor:
for row in cursor:
date_dia, delai_co, date_f_d = row
if date_dia is None or date_dia == "":
# Si date_dia est nul ou vide, ne rien renseigner dans date_f_d
row[2] = None
elif delai_co in ["Aucun", "Indefini", None, ""]:
# Si delai_co est "Aucun", "Indefini", nul ou vide, mettre nul ou ne rien renseigner dans date_f_d
row[2] = None
else:
if delai_co == "1_an":
date_f_d = date_dia + timedelta(days=365)
elif delai_co == "2_ans":
date_f_d = date_dia + timedelta(days=365*2)
elif delai_co == "3_ans":
date_f_d = date_dia + timedelta(days=365*3)
# Update the field
row[2] = date_f_d
cursor.updateRow(row) |
Partager