Problems with deicimal point when calculating sum in script

Discussion created by RichardNilsson on Dec 18, 2013
Latest reply on Dec 20, 2013 by doug.sands

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 =
#note value can be rounded depending on field type

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 are

Display Name - Data Type
Layer or Table - Table
Input Field - Field
Output Field - Field
Output Layer - Table

Parameter Properties

Display Name  - Property - Value
Layer or Table - Type         - Required
Layer or Table - Direction    - Input
Layer or Table - Multivalue   - No
Layer or Table - Filter          - None
Input Field      - Type          - Required
Input Field      - Direction     - Input
Input Field      - Multivalue    - No
Input Field      - Filter           - None
Input Field      - Obtained from - Layer or Table
Output Field    - Type               - Required
Output Field    - Direction          - Input
Output Field    - Multivalue         - No
Output Field    - Filter                - None
Output Field    - Obtained from    - Layer or Table
Output Layer    - Type        - Derived
Output Layer    - Direction    - Output
Output Layer    - Multivalue   - No
Output Layer     - Filter       - None

My 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!

Edit: The script runs in PyScript, but the output only shows periods instead of commas.