1

I'm trying to use the field calculator in ArcMap, however my code is way too long (1337 lines) and there seems to be a character limit:

I'm only allowed to paste the first 103 lines.

Is there an easy work around? I'm using ArcMap 10.1.

  • 3
    You may want to consider just making a script tool. – j.stanfield Jan 12 '18 at 20:14
  • 1
    if you really wanna be 1337 and use all 1337 lines you should port it to pycharm – atxgis Jan 12 '18 at 23:10
  • 1
    Please edit your question to provide more info about the code you are trying to use, and what you're trying to calculate. To me it seems your question should more be around how to produce a shorter code for the field calculator. To me 1000+ lines sounds much too long for the field calculator. – Midavalo Jan 13 '18 at 1:27
7

Instead of using the Field Calculator, consider writing a Python script that uses an Update Cursor from the arcpy.da module. That way you can theoretically run any length of code you like on each row, as well as use values from other fields (nest cursors to get values from other rows), or constants. You could run that from the command line and simply load your results into a GUI instance later.

Another alternative is to do the same from the Python Window in the Arc GUI.

http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-data-access/updatecursor-class.htm

0

To directly answer your question Does Field Calculator have a word limit?, I would suggest there isn't a word limit as such (as that can be fairly arbitrary - how long can each word be?). Rather there will be a limit to the number of characters accepted in the Field Calculator text box.

There is a character limit of 30,000 characters


In trying to determine the character limit I created three scenarios. One where there is 10 characters per line, one with 20, and the third with 100 characters in every line.

At 10 characters per line I appear to be limited to 25000 characters (2500 lines).
But at 20 characters per line I am limited to 27274 characters (1364 lines, with the limit hitting part way through that last line).
And with 100 characters per line I'm limited to 29412 characters (295 lines, again breaking mid line).

Allowing 2 characters for a new line (CR/LF) would place the character limit at exactly 30000 characters in all three examples.

25000 + 2500 + 2500 = 30000 (including the CR/LF, creating a blank last line)
27274 + 1363 + 1363 = 30000 (not including a CR/LF as it broke mid line)
29412 +  294 +  294 = 30000 (not including a CR/LF as it broke mid line)

Example of sample text showing where the limit hit (screenshot from Notepad++):

10 Chars per line:
enter image description here
enter image description here

20 Chars per line:
enter image description here
enter image description here

100 Chars per line:
enter image description here
enter image description here


And if you're interested, the code I used to create my lines of characters is just simple python:

i = 10
while i <= 40000:
    # Lines of 10 characters
    print "{}".format(str(i).zfill(10))
    i += 10

    # Lines of 20 characters
    print "{}{}".format(str(i).zfill(10),str(i+10).zfill(10))
    i += 20

    # Lines of 100 characters
    print "{}{}{}{}{}{}{}{}{}{}".format(str(i).zfill(10),str(i+10).zfill(10),str(i+20).zfill(10),str(i+30).zfill(10),str(i+40).zfill(10),str(i+50).zfill(10),str(i+60).zfill(10),str(i+70).zfill(10),str(i+80).zfill(10),str(i+90).zfill(10))
    i += 100

I just copied the output directly into the Field Calculator and looked at the numbers at the end to get the character count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.