Select to view content in your preferred language

Model Builder Calculate Field Hangs

3804
5
12-30-2010 06:01 AM
PhilipRichardson
Emerging Contributor
I have a built a model to add several fields to a table, then calculate the values from existing fields.  This would appear to be a simple task, but model builder hangs after a few iterations.  The problem seems to be with empty records.  It reports an error for each empty record it encounters, then it just seems to lock up.  I can accomplish the task in ArcMap by just telling Field Calculator to ignore the errors, but I was hoping to automate the task.  I have also tried Pyton script, but it hangs just like Model Builder.  Any thoughts?
0 Kudos
5 Replies
ChrisSnyder
Honored Contributor
As memory serves, this was a big issue with v9.2 (Field Calculator hangs)... I recall having this issue especially for large tables > 500k records.

The one guaranteed fix is to use an update cursor via a Python script in lieu of the CalculateField tool.
0 Kudos
LornaMurison
Regular Contributor
If the problem is only with empty records, could you just add a clause in your calculate field expression that deals with empty records.  i.e. if Field1  = "" then Field2 = "" (or if Field1 isnull ...)?
0 Kudos
PhilipRichardson
Emerging Contributor
You are correct.  The problem exists with nulls and empty records.  I just figured this out today, by selecting only records with values before the field calculation.  It adds some steps in the model, but it now works.
0 Kudos
PhilipRichardson
Emerging Contributor
Unfortunately, the model is not working like I originally had hoped.  The difficulty is with zero length string records.  I have been trying to get a VB expression that would identify zero-length records. If a zero-length record exists, then populate the new field with a null, else calculate the new record.  The model converts a date expressed as a string to an actual date record.
0 Kudos
PhilipRichardson
Emerging Contributor
This is what I decided to do.  Instead of populating the new field with nulls, I used a date 1/1/1900, which I can use as a flag later.  To handle the zero-length string problem, I needed a VB script to recognize a zero-length cell, and substitute a date 1/1/1900.

dim pstart1 as string
dim pstart2 as string
pstart1 = [Date_Start]
if pstart1 = "" then
pstart2 = "1900-01-01"
else
pstart2 = pstart1
end if


[Date_Start] is the original field with dates expressed as a string.  The field calculator converts [Date_Start] to [New_Date], which is date format.  [New_Date] = pstart2
0 Kudos