[GIS] IF THEN statements in ArcGIS Field Calculator

arcgis-desktopfield-calculatorpython-parser

I'm not sure if this would be best handled in vbscript or python, and unfortunately I'm less than novice at both so I'll take any help I can get from the exchange.

I'm trying to take my streets layer and remove the "type" field for a certain set of street names. Any street named "Avenue A", "Avenue B", Avenue C" and so forth would need the "TYPE" field emptied out. But all other streets and street types would remind.

A little explanation as to the why may help you understand my plight a little better: We have an emergency response software at my municipality that uses both the prefix, subname, and type to display the streets data, as well as, track calls and statistics for each street. All streets display properly except for the "Avenue A" type streets which show up "Avenue A AVE". Any other AVE type street displays properly, for example: Baltic AVE, Crawford AVE, etc. But the "Avenue (letter)" streets will not with the "TYPE" field populated. Hope this makes sense.

So what I am needing is a field calculator script that will search for any [SUBNAME] "AVENUE #" street and blank out the [TYPE] field for it. I tried a little SQL with my inadequate knowledge of VBscript to generate the below (no it didnt work):

IF [SUBNAME]="AVENUE *" THEN REPLACE([TYPE],"AVE","")

Best Answer

use (replace [type], "AVENUE %", "") There are many ways to use field calculator.
Trying to use the if then statement in my experience you are likely going to want to try to learn some regex. It is very powerful for finding string or numeric sequences and allowing you to make changes.
Short of needing more than what you already eluded in your question you can easily accomplish with some more basic field calculator statements.
Here are some links to old and new esri documentation for both python and vbscript that will help make you a guru.
An old vbscript help pdf but still useful.
A 9.3 doc for using a gp tool.
10.3 document with fundementals
10.3 field calculator examples
Or to not make the change in the field permanently but to change how you label.
Define separate sql statements for the types and label each differently.
define different

Related Question