POST
|
I am trying to use dictionary to help update a field. I have the following but I am getting an error. Basically, if field "Type" has PVT, I want it to update with "Private" and if Pub, I want it to update with "Public". the filed doesn't get updated. I am assuming that dict is wrong? import arcpy
fc = r"C:\Temp\test.gdb\Testb"
search_feats ={f[0]:(f[:1] for f in arcpy.da.SearchCursor(fc,"Type")}
print(search_feats) #'OID@', 'Type'
place_dict = {"PVT": "Private",
"Pub": "Public"
}
with arcpy.da.UpdateCursor(fc,"Type") as upd_cur:
for upd_row in upd_cur:
if upd_row[0] in place_dict:
upd_row[0] = place_dict.get(search_feats[upd_row[0]], upd_row[0])
upd_cur.updateRow(upd_row)
... View more
02-16-2023
12:08 PM
|
0
|
5
|
1035
|
POST
|
After setting up the model to use the delete tool and create file geodatabase tool, then scheduling it to run this morning, I get the warnings, the geodatabase already exists and so does the PI_Tax feature class. So nothing was deleted.
... View more
01-20-2023
07:19 AM
|
0
|
0
|
1213
|
POST
|
I guess there is not in this particular situation, I could delete the geodatabase with the delete tool and then create a new one. I would still like to know why it's not delete with the Calculate Value Tool, if I run it through the task scheduler in Pro.
... View more
01-19-2023
01:29 PM
|
0
|
0
|
1231
|
POST
|
I am trying to using this in a Calculate Value tool. I am still seeing the datasets in there with Pro and I do see a bunch of files in the FGDB through Windows explorer. The odd thing that I noticed is if I select the Calculate Value Tool in the Model Builder View window, right click and select run, its runs fine, everything gets deleted. If I right click on the Scheduled Model with this Calculate Value Tool in the Scheduled Tools window and selecting run, I get a warning that, "PI_Taxp" already exists in the C:/Temp/BoardPI.gdb". So it's not being deleted. So it appears that if it's scheduled in a Pro project, it doesn't run...?
... View more
01-19-2023
12:42 PM
|
0
|
1
|
1235
|
POST
|
I am trying to delete all feature classes, tables and datasets from a file database and the issue is sometimes it works and sometimes it doesn't. I trying the following but none of them works consistently. My thought is that, os.path.exists would be more reliable. import arcpy, os
def deletePI():
try:
arcpy.env.workspace = "C:/Temp/DashboardPI.gdb"
fc_list = arcpy.ListFeatureClasses()
tables = arcpy.ListTables()
ds_list = arcpy.ListDatasets()
#feature classes
for fc in fc_list:
arcpy.Delete_management(fc)
#tables
for table in tables:
arcpy.Delete_management(table)
#data sets
for ds in ds_list:
arcpy.Delete_management(ds)
except:
pass import arcpy, os
def deletePI():
try:
arcpy.env.workspace = "C:/Temp/DashboardPI.gdb"
if os.path.exists("C:/Temp/BoardPI.gdb/PI_Taxp") == True:
arcpy.Delete_management(r"C:/Temp/boardPI.gdb/PI_Taxp")
... View more
01-19-2023
09:48 AM
|
0
|
9
|
1247
|
POST
|
The ValDict and the where do have values, I was just trying to post quickly and didn't include them. I did try the exception as e: but no message gets printed.
... View more
01-06-2023
12:57 PM
|
0
|
0
|
799
|
POST
|
I am trying the following but I only get 25 in the progress field on features that have something in "Field5". It seems to stop if it encounters a blank record in Field5. What am i doing wrong? valDict{}
with arcpy.da.UpdateCursor(table2, ["OBJECTID","Field1","Field2","Field3","Field4","Field5","Field6", "Field7", "Field8","Progress"],
where) as cursor:
for row in cursor:
try:
if row[5] is None: #if row[5] not in (None, "", " "):
continue
if row[5] in list1:
print ("{} is in list".format(row[0]))
row[9] = valDict.get(row[5]) if row[6] == "Pass" else valDict.get(row[5], 25) - 25
cursor.updateRow(row)
except:
continue
... View more
01-06-2023
12:15 PM
|
0
|
5
|
827
|
POST
|
Jeffk, I was trying to impalement your suggestion but I am having trouble getting the code to work. Hopefully I can explain it correctly, I would really appreciate the help to understand dictionaries in this type of situations. If reviews 1-4 equal approved then, progress filed = 15%, if three out of the four review are pass then Progress field = 0% If Reviews1-4 fields = Approved & Event field = Foundation or Setback or Shear Panel 1 & EventRes1 field = Pass, then Progress field = 15%, if if Reviews1-4 = Approved & Event field = Foundation or Setback or Shear Panel 1 & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress field = 15% if If Reviews1-4 fields = Approved & Event field = Framing or BC- Framing & EventRes1 field = Pass, then Progress field = 50%, if If Reviews1-4 fields = Approved & Event field = Framing or BC- Framing & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress, then progress field = 25% if If Reviews1-4 fields = Approved & Event field = Insulation or Stucco & EventRes1 field = Pass, then Progress field = 75%, if If Reviews1-4 fields = Approved & Event field = Insulation & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress, then progress field = 50% if If Reviews1-4 fields = Approved & Event field = Final & EventRes1 field = Pass, then Progress field = 100%, if If Reviews1-4 fields = Approved & Event field = Final & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress, then progress field = 75% If both fields "Certif", "CertifDate" are populated , then Progress = 100% Some fields are blank.
... View more
01-04-2023
03:07 PM
|
0
|
2
|
1675
|
POST
|
Interesting, I will have to try to use the dictionary option.
... View more
12-12-2022
09:27 AM
|
0
|
0
|
1729
|
POST
|
Thank you for the visual of formatting the if, elf and else. Line 24 would just be "Pass", so i can continue.
... View more
12-12-2022
09:25 AM
|
0
|
0
|
1729
|
POST
|
I have a table that I need to do multiple nested if else it appears that only the last if else is used and field only gets populated with 15, there are some that meet the 25,35 and 45 but they don't get updated. what am I doing wrong? where = "AppType = 'SFR Active'"
with arcpy.da.UpdateCursor(table1, ["Field1","Field12","Field3","Field4","Field5", "Field6", "Field7","Field8"], where) as cursor:
for row in cursor:
#if row[0] is None:
#continue
if row[0] == "Approved" and row[1] == "Approved" and row[2] == "Approved" and row[3] is not None and row[4] == "Pass":
row[7] = 15
else:
row[7] = 0
if row[3] == "In_1" and row[4] == "Pass":
row[7] = 25
else:
row[7] = 15
if row[3] == "In_2" and row[4] == "Pass":
row[7] = 35
else:
row[7] = 25
if row[3] == "In_3" and row[4] == "Pass":
row[7] = 45
else:
row[7] = 35
cursor.updateRow(row)
... View more
12-09-2022
03:01 PM
|
0
|
9
|
1854
|
POST
|
I have had this issue with almost every model I have created and "tried" to schedule. I have done what you stated multiple times, over and over and still some scheduled models don't work. In my opinion Pro is so JUNKY it has so much flaws. Its hard to get any work done.
... View more
10-27-2022
11:37 AM
|
1
|
0
|
2191
|
Title | Kudos | Posted |
---|---|---|
1 | 10-27-2022 11:37 AM | |
1 | 10-31-2023 10:16 AM | |
1 | 02-16-2023 01:50 PM | |
1 | 08-11-2021 11:13 AM | |
1 | 01-06-2021 10:45 AM |
Online Status |
Offline
|
Date Last Visited |
09-10-2024
10:42 AM
|