Hi!First, I am very new to python! And not very skilled in programing at all. So bare with me, please! If there is anyone out there that might be interested in helping me, please be as basic as possible. 😉Anyhow, I am trying to use a script in a toolbox I created. The script sums the rows in a field and fills the result in another field.
import arcgisscripting, sys
gp = arcgisscripting.create()
intable = sys.argv[1]
field = sys.argv[2]
# Create search cursor
rows = gp.SearchCursor(intable)
row = rows.Next()
x = 0.0
# Enter while loop for each feature/row
while row:
x += row.getvalue(field)
print x
row = rows.next()
#note value can be rounded depending on field type
gp.calculatefield(intable,sys.argv[3],float(x),"PYTHON")
Kudos goes out to Terry Giles for posting this script here! Both input and output fields, in the table, are set to be of the type Float.Parameters in the properties areDisplay Name - Data Type-----------------------------------Layer or Table - TableInput Field - FieldOutput Field - FieldOutput Layer - Table-----------------------------------Parameter Properties Display Name - Property - Value-----------------------------------Layer or Table - Type - RequiredLayer or Table - Direction - InputLayer or Table - Multivalue - NoLayer or Table - Filter - None-----------------------Input Field - Type - RequiredInput Field - Direction - InputInput Field - Multivalue - NoInput Field - Filter - NoneInput Field - Obtained from - Layer or Table-----------------------Output Field - Type - RequiredOutput Field - Direction - InputOutput Field - Multivalue - NoOutput Field - Filter - NoneOutput Field - Obtained from - Layer or Table-----------------------Output Layer - Type - DerivedOutput Layer - Direction - OutputOutput Layer - Multivalue - NoOutput Layer - Filter - NoneMy problem is that the script only works for integers. All I get when calculating numbers containing a decimal point is null. At least that is what ends up in my field... I had a suspicion that this might be a localization problem. The numbers used for calculation are in Swedish, i.e 8,2. Using a comma sign as decimal point. BUT, When i run a check on locales i get: getlocale = ('Swedish_Sweden', '1252'), getdefaultlocale = ('sv_SE', 'cp1252') and getpreferredencoding = cp1252. Which, to me, looks correct. So that smashes my suspicion. 😞I am using ArcGIS 10.1 SP1 for Desktop with standard license. This takes place on a Swedish installation, but set to show English. If I understand it correctly I am running Python 2.7. I have searched through all possible forums in hunt for solution, my hope now goes out to you guys here!Thanks in advance!/RichardEdit: The script runs in PyScript, but the output only shows periods instead of commas.