POST
|
I want to construct a replace statement in my python script through the following python code below; arcpy.CalculateField_management("Mainfb_Stage_P","AFileN","!ABFileN!","PYTHON_9.3","replace(ABFileN, "/","-")") But i keep getting the error below; Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: unsupported operand type(s) for /: 'str' and 'str' Anyone with a wonderful suggestion. Thanks
... View more
09-20-2017
07:36 AM
|
0
|
2
|
545
|
POST
|
Evening Dan, i know its a long time since i started this thread your code works but it leaves zeros instead of the actual total considering the concatenations from the previous row. Please kindly check my code out so as to see if you can enhance it further? Form1 = "Form1" Calculated_EA1=0 with arcpy.da.UpdateCursor(Form1, ["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"]) as cursor: for row in cursor: Calculated_EA2 = row[1] row[2] = (Calculated_EA1 + Calculated_EA2) Calculated_EA1 += Calculated_EA2 if row[2] >= 500: row[2] = Calculated_EA2 - 500 cursor.updateRow(row)
... View more
09-18-2016
01:33 PM
|
0
|
4
|
796
|
POST
|
I'm actually running it from a script. This is what it should look like really; When the totaling reaches the 500 threshold, it should then start again from zero (0).
... View more
07-21-2016
06:11 AM
|
0
|
0
|
796
|
POST
|
This was what i got when i tried the script And this is the script below; CensusBldForm = "SCensusBldForm" vsum = 0 flds = ["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"] with arcpy.da.UpdateCursor(CensusBldForm, flds) as cursor: for row in cursor: vsum += row[1] if vsum >= 500: vsum = vsum - 500 row[2] = vsum cursor.updateRow(row)
... View more
07-21-2016
05:37 AM
|
0
|
7
|
796
|
POST
|
I got the error below when i incorporated the lines of code you suggested; vsum = vsum + row[1] TypeError: unsupported operand type(s) for +: 'float' and 'NoneType' See my code; CensusBldForm = "SCensusBldForm" vsum = 0 flds = ["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"] with arcpy.da.UpdateCursor(CensusBldForm, flds) as cursor: for row in cursor: vsum = vsum + row[1] if vsum >= 500: vsum = vsum - 500 row[2] = vsum cursor.updateRow(row) What do you think i'm doing wrong?
... View more
07-13-2016
01:19 PM
|
0
|
9
|
781
|
POST
|
I'm trying to create a distinct list of values in my Python addin combo box drop down list; i already have the script that actually shows all the values of the field appended to my combo box drop down. What i intend to achieve with this is to have a list of distinct values on my drop down - see my code below; def __init__(self):
OBJECTID = []
for row in arcpy.SearchCursor("BldForm"):
OBJECTID.append(row.Combo)
self.items = sorted(OBJECTID)
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWW'
self.width = 'WWWWWWWWWWWW'
def onSelChange(self, selection):
mxd = arcpy.mapping.MapDocument("Current")
for df in arcpy.mapping.ListDataFrames(mxd):
if df.name == "Layers":
dfmain = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
OBJECTID = []
for row in arcpy.SearchCursor("BldForm"):
OBJECTID.append(row.Combo) I'll kindly appreciate your help on this.
... View more
07-13-2016
01:38 AM
|
0
|
3
|
1913
|
POST
|
Thanks i changed from the default version to another version and i didn't get any error and my edits where retained as well.
... View more
04-26-2016
03:29 PM
|
0
|
0
|
847
|
POST
|
Thanks, i'm actually running my script against an SDE Geodatabase
... View more
04-26-2016
03:20 PM
|
0
|
0
|
847
|
POST
|
This is the error message i get when i want to save edits; Kindly assist me please. Thanks in advance
... View more
04-26-2016
03:12 PM
|
0
|
0
|
847
|
POST
|
My edits don't get saved after running the script, because i have to start an edit session before running the script; CensusBldForm = "CensusBldForm" Calculated_EA1=0 with arcpy.da.UpdateCursor(CensusBldForm, ["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"]) as cursor: for row in cursor: Calculated_EA2 = row[1] row[2] = (Calculated_EA1 + Calculated_EA2) Calculated_EA1 += Calculated_EA2 cursor.updateRow(row) What do you think might be wrong or better still can i get it to run without starting an edit session i.e using a arcpy.UpdateCursor instead of arcpy.da.UpdateCursor? Thanks
... View more
04-26-2016
02:38 PM
|
0
|
1
|
847
|
Title | Kudos | Posted |
---|---|---|
1 | 10-19-2015 08:49 AM | |
1 | 10-15-2013 04:42 AM | |
1 | 09-20-2016 03:45 AM | |
2 | 09-25-2016 03:50 PM | |
1 | 08-25-2012 09:15 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|