4

I have a set of States in the US and for each one I want to perform a set of tasks within ModelBuilder. When I type the state as a string parameter the model runs fine but I have to type in the State, then wait for the model to run, then type in the next state etc. I'd much rather just click go and have the model iterate through each of the State names in the list.

I created a CSV file with each of the state names and then set that as the input table in Iterate Field Values. For some reason, the first output is the number 1. This causes the model to crash because it relies on the State name in order to properly load files. For example, passing "Rhode_Island" into the model tells it to go to the Rhode Island folder on my computer and load the files.

5
  • Starting with the most obvious thing first: did you verify that the iterator is reading from the correct field in the csv? You aren't reading an ID number? Oct 9, 2015 at 18:34
  • The input table is set to the csv file, Field is set to STATE (column with the state names) and data type is string. Oct 9, 2015 at 18:39
  • 1
    Is the output of the iterator used directly or are you using it as a variable somewhere (is there a line coming from it going to another process)? Oct 9, 2015 at 18:40
  • Yeah it sounds like the iterator is being used directly. Can we get some screenshots, code?
    – Thomas
    Oct 9, 2015 at 18:41
  • At the beginning of the code I Parse Paths, it appears it goes through once with a value of 1 before executing Iterate Field Values. This may be the issue as Iterate Field Values needs to be executed first. Any ideas on how to make it execute first? I checked this in a separate model where I added the iterate field values bubble first then added a single Parse Path, the output started where it should have at the first state in the list and the first thing to be executed was Iterate Field Value. Oct 9, 2015 at 18:50

2 Answers 2

6

You need the iterator to be a precondition of your first tool, which sounds like it's Parse Path. To do that, follow the directions in the docs:

  1. Right-click a tool element and select Properties.
  2. In the Properties window, click the Precondition tab and check the variable for which you want to make a precondition to the tool.

In this case you'd choose the output variable from the iterator to be the precondition in step 2.

This will cause the iterator to be run before the Parse Path tool.

2

I ended up starting over by making a new model where the first thing I input was the Iterate Field Values tiles. From the details logs it appears this is now the first thing being executed and it begins correctly with the first item in my list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.