enter image description here

I created a model which geocodes addresses using an excel file. I wanted to know if there is a way I can give a different excel file every time to the model. I do not want to manually add a new excel file every time.

Can a python script point to a folder with multiple excel files and give them, one by one as an input to ModelBuilder?

  • My question is, can i pass a variable to my model from a python script? @John – PowerToYou Jul 14 '17 at 18:40
  • Ok, got it. In that case, if you've correctly set up model parameters, then you just execute the model from within python like you would any built in tool, including putting model parameters (in order) in the script. Maybe gis.stackexchange.com/a/118310/22780 would help. If still unclear, let me know and I can try writing up an answer. – John Jul 14 '17 at 18:47
  • And if needing to loop through files/folders via Python, use ArcPy's Walk (desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-data-access/…) or Python's Walk (docs.python.org/2/library/os.html#os.walk) – John Jul 14 '17 at 18:50
  • 1
    You need to turn what appears to be "records to geocode" into an actual model parameter. Right click on it and select "Model Parameter". Then save the model, close it, and try running (not editing) the model and see if it gives you the selection dialog it sounds like you're looking for. – John Jul 14 '17 at 19:43

Within ModelBuilder, under the Insert tab, there is the option to add an iterator. You can choose the "Files" type, point that to your folder, then your model will iterate through the files in that folder one by one. You can then use that file as the input to your geocoding solution

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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