Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I do some script for a shapefile's table.

And this script works for 2 fields and do not for other ones, because of:

ERROR 000728: Field FID_158_01 does not exist within table

But this field is fine and EXIST!

enter image description here

Script executed in field calculator. I take field names from Iterator (Iterate MultiValue).

Expression:

a(!%field_name%!)

Codeblock:

def a(f):
  if f==0:
    z=1
    return z
  elif f==(-1):
    z=0
    return z
  elif f==(1):
    z=1
    return z

Crashlog:

Executing (EXTENT redo math): Model13 H:\TEST\CHECK.shp FID_154_01;FID_153_01;FID_158_01;FID_155_01;FID_153_02
Start Time: Fri Sep 28 14:12:22 2012
Executing (Iterate Multivalue): IterateMultivalue FID_154_01;FID_153_01;FID_158_01;FID_155_01;FID_153_02
Start Time: Fri Sep 28 14:12:23 2012
Succeeded at Fri Sep 28 14:12:23 2012 (Elapsed Time: 0,00 seconds)
Executing (Calculate Field): CalculateField H:\TEST\CHECK.shp FID_154_01 a(!FID_154_01!) PYTHON_9.3 "def a(f):\n  if f==0:\n    z=1\n    return z\n  elif f==(-1):\n    z=0\n    return z\n  elif f==(1):\n    z=1\n    return z"
Start Time: Fri Sep 28 14:12:23 2012
Succeeded at Fri Sep 28 14:12:23 2012 (Elapsed Time: 0,00 seconds)
Executing (Iterate Multivalue): IterateMultivalue FID_154_01;FID_153_01;FID_158_01;FID_155_01;FID_153_02
Start Time: Fri Sep 28 14:12:24 2012
Succeeded at Fri Sep 28 14:12:24 2012 (Elapsed Time: 0,00 seconds)
Executing (Calculate Field): CalculateField H:\TEST\CHECK.shp FID_153_01 a(!FID_153_01!) PYTHON_9.3 "def a(f):\n  if f==0:\n    z=1\n    return z\n  elif f==(-1):\n    z=0\n    return z\n  elif f==(1):\n    z=1\n    return z"
Start Time: Fri Sep 28 14:12:24 2012
Succeeded at Fri Sep 28 14:12:24 2012 (Elapsed Time: 0,00 seconds)
Executing (Iterate Multivalue): IterateMultivalue FID_154_01;FID_153_01;FID_158_01;FID_155_01;FID_153_02
Start Time: Fri Sep 28 14:12:24 2012
Succeeded at Fri Sep 28 14:12:24 2012 (Elapsed Time: 0,00 seconds)
Executing (Calculate Field): CalculateField H:\TEST\CHECK.shp FID_158_01 a(!FID_158_01!) PYTHON_9.3 "def a(f):\n  if f==0:\n    z=1\n    return z\n  elif f==(-1):\n    z=0\n    return z\n  elif f==(1):\n    z=1\n    return z"
Start Time: Fri Sep 28 14:12:25 2012
Failed to execute. Parameters are not valid.
ERROR 000728: Field FID_158_01 does not exist within table
Failed to execute (Calculate Field).
Failed at Fri Sep 28 14:12:25 2012 (Elapsed Time: 0,00 seconds)
Failed to execute (EXTENT redo math).
Failed at Fri Sep 28 14:12:25 2012 (Elapsed Time: 3,00 seconds)

Any ideas?

When i do all the steps in one model it gives me an error.

But when i just make union output file then stop the model and RUN THE SECOND part with field calculations -> error dissapeared and all works fine!!!

share|improve this question
    
running arcpy under Arcmap seems not very stable, i had some problems like this, i recommend to debug arcpy code under Pyscripter or any python console. –  geogeek Sep 28 '12 at 8:43
2  
Be careful that you fieldnames don't include any spaces at the end, you cant see it of course, but it will affect the code. –  U2ros Sep 28 '12 at 10:46
2  
While this may not be the case, I am guessing from the elapsed time using a comma for a decimal separator that your may not be using ANSI characters. If one of your fields has a name that is using non-ANSI characters (UTF for example), it will fail. ESRI has been trying to support UTF characters, but each dBase field name is only 10 bytes (hence the 10 ANSI character field name - read more here). I would suggest checking out if you used UTF characters by accident when creating those fields, or trying in a GDB. –  Michalis Avraam Sep 28 '12 at 15:42
2  
Looks like there is some refresh bug appeared and when u close script shapefile's field names refreshed. Wasted 4 days to discover that shit =( –  Vasiya Oct 1 '12 at 5:22
1  
This thread mentions the same refresh issue and suggests a manual way to force a refresh but its for .NET, I wonder if there is an equivalent in arcpy. –  mindless.panda Dec 21 '12 at 18:02
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.