Select to view content in your preferred language

Find and Replace Won't Replace......

2262
4
05-23-2013 04:48 AM
JamesReed1
Deactivated User
I am trying to replace a <Null> value in a selected field. When I do a find and replace I get an error that no fields have been detected. I have put in to find <Null> and replace it with the info that I want. I have selected the field but I still get this error. Can anyone help me with this? Is there a better or another way to do this? It just takes too long to select each field and type in the replacement info.
Tags (2)
0 Kudos
4 Replies
ganeshnarim
Emerging Contributor
I am trying to replace a <Null> value in a selected field. When I do a find and replace I get an error that no fields have been detected. I have put in to find <Null> and replace it with the info that I want. I have selected the field but I still get this error. Can anyone help me with this? Is there a better or another way to do this? It just takes too long to select each field and type in the replacement info.


Hi,

one Quick answer is for you is that convert feature class into shape file,Shapefile's do not support Null entries and automatically convert Null to zero.

You didn't mention that where you want to change the <Null> Values and what you want to replace with. Ok this time i assume that you want to replace <Null> values with some "x" value then try this script simple and straightforward. you just replace 0 to your value and make sure that you put a right path for "in_data"

import arcpy
import os

# replace data path with your OWN data.
in_data = r"C:\Data\Sample.mdb\NullValues"

field_list = []
numeric_fields = ["Double", "Integer", "SmallInteger"]

fields = arcpy.ListFields(in_data)
for field in fields:
    if (field.type in numeric_fields):
        field_list.append(field.name)

# convert the list of fields to a semicolor delimited string
fields = ";".join(field_list)  

rows = arcpy.UpdateCursor(in_data, '', '', fields)
count = len(field_list)

for row in rows:
    for k in range(count):
        if row.isNull(field_list):
            row.setValue(field_list, 0)
        rows.updateRow(row)


Let me know if you face any issues...

Gud Luck...!!
0 Kudos
RobertBorchert
Honored Contributor
Find and Replace cannot find nothing.

You need to do a query using Select by Attributes.  The use Field Calculator or the Attributes window to insert a value.

NOW I do not recommend this.

You can also open your database in MS Access.  Open the table that contains the <Null> values you want to replace.

Press Control H to bring up the Find Replace.  Insert the word

Null

and have it match Whole Field.   This way you can replace many thousands of null values with something.


Now I must as why you want to get rid of the null values?  Is it only because you do not want to see the null value but would rather have a blank space.

Keep in mind when you replace a <null> with a value you are increasing the size of your database and it could effect performance if you do enough of them.



I am trying to replace a <Null> value in a selected field. When I do a find and replace I get an error that no fields have been detected. I have put in to find <Null> and replace it with the info that I want. I have selected the field but I still get this error. Can anyone help me with this? Is there a better or another way to do this? It just takes too long to select each field and type in the replacement info.
0 Kudos
JoeBorgione
MVP Emeritus
Or use the caveman simple approach and select <your_field> is null. 

Then use the field calculator on the selected set such that <your_field> = Your_Specified_Value.
That should just about do it....
0 Kudos
RichardFairhurst
MVP Alum
You can use this Field Calculator expression to replace Null values in any field without preselecting records.  Of course it is limited to working on one field at a time.  This approach is not recommended for SDE version editing, but it is fine for file geodatabases and shapefiles.

Parser: VBScript

Prelogic codeblock:
If IsNull() Then ' Substitute  with your real field name here
  Output = 0 ' Specify the replacement value for Null here. Make sure it is valid for the field you are calculating.
Else
  Output =  ' Substitute  with your real field name here
End If


Expression: Output
0 Kudos