to assist with symbology, I'm trying to populate a column with alternate 1 & 0 so I can filter and symbolise alternate records. I need a simple method to auto complete a table of approx 5000 records. Can anyone help?
Solved! Go to Solution.
Stuart,
Timothy's code is the complete copy and paste code that you need to put in the field calculator.
The only difference is that your field would be:
[FID] Mod 2
Just Copy and Paste the above line in the Field Calculator window in ArcMap.
python processor, use the FID field or any other sequential field
>>> from math import fmod
>>> for i in range(20):
... if fmod(i,2) == 0:
... print 0
... else:
... print 1
...
0
1
0
1
0
1
.......etc
1
0
1
0
1
0
1
>>>
python parser, enable the code block this is the function to use and in the expression box you could use ones_zeros(!FID!) (ps... haven't tried the code block but the above python syntax is the key
from math import fmod
def ones_zeros(your_field):
if fmod(your_field,2) == 0: print 0
else: print 1
Thanks for the suggestion Dan,
Unfortunately that didn't work. I mistakenly forgot to mention I'm using ArcGIS Basic 9.3.1 on an enterprise licence and I'm pretty sure the PythonWin Application hasn't been installed. Is there a way I can do this via the field calculator or the command line window?
I'm afraid my scripting / coding skills are pretty much zero.
You should be able to just use the Mod operator in the Field Calculator:
[ObjectID] Mod 2
Thanks Timothy,
Any chance you could supply the full script for the Field calculator (9.3.1)? I have no idea what the Mod operator is.
Sorry - scripting dummy here.
I think it is just "mod", i mean, you can input "i=5 mod 2" which will make i=1. So, "[ObjectID] Mod 2", as Hales mentioned above, is what you can use directly.
Just some additional info for this question:
I'm using ArcGIS 9.3.1 Basic
I only have access to the command line window or the field calculator. All other scripting options are unavailable
I have pretty much no skills in scripting so really am looking for the complete answer (cut & paste??)
The only sequential field in the attribute table is the FID column.
Hopefully someone can help me with an appropriate code. Thanks
Stuart,
Timothy's code is the complete copy and paste code that you need to put in the field calculator.
The only difference is that your field would be:
[FID] Mod 2
Just Copy and Paste the above line in the Field Calculator window in ArcMap.
Thanks guys.
Worked perfectly.