I have a string field 'Oneway' with three values '+' '-' and Null showing a street accessibility, I would like to replace them with values 'F' 'T' and null as the script for Network dataset expect these values.However it seems that it is not possible to replace values if Null values are present. I tried also changing the field type to double or text but the field properties are not editable somehow (I tried this in arc catalog). I am only able to replace value '+' and '-' with numbers using the field calculator but need to replace them with letters.
An automated way of doing this task is by running a python function within Field Calculator (no selecting and reverse selecting required), see example below:
Additionally, if you want to replace NULL with an empty string just add these two statements:
elif value is None: return ''
Here is how I would do this:
- Select all rows where oneway = "+" then run a field calculate to set them to "F"
- Select all rows where oneway = "-" then run a field calculate to set them to "T"
- Select all rows where oneway = "F" AND oneway = "T", reverse the selection then run the field calculate and set remaining rows to "null".
I had this problem after having done a spatial join - I had null value which in my case needed to changed to 0. I solved it using the following method:
Toolbox 'Table Select' (This extracts all the Fields to a table)
Toolbox 'Table to Excel'
I then opened the resulting Excel file in Excel and using Replace, replaced [Blank] with 0. You then need to format the cells, cell with numbers in them need to be formatted as numbers and text as text etc.
Toolbox 'Excel to Table' (All the null values are now 0).
Join by attributes to the original feature.
It all worked very well! (Sometimes it is much easier to do things in other programs!)
- Select by attribute for '+'
- Start editor
- Click attributes on the editor toolbar
- Change '+' to 'F' for the selected records in the the field
- Repeat for '-' to 'T'