Iterate Field Values

882
8
03-10-2017 02:07 PM
ChrisHolmes
Occasional Contributor III

Hello everyone,

I have the following model. I would like the Iterate Field Values to locate Addresses.csv based on using LocNo and Year in the path. LocNo and Year are both outputs from Get LocNo And Year. It won't run in this manner.

This is the error message returned:

Any help appreciated,

Thanks

Tags (1)
0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

the error seems to be related to the fact it is trying to find a table with addresses.csv appended to it.  It there any chance you are iterating the wrong thing?  or do you have a bunch of csv files with various names which end in Addresses.csv?

0 Kudos
ChrisHolmes
Occasional Contributor III

Thanks for the reply Dan. The folder has one file named addresses.csv which has a field in it called address which has numerous addresses in it.

I did a test before where I hard coded the path to the csv file into the iterator (O:\plan\luam\1p2007\2018\LOC2018-0027\addresses.csv) and it worked fine iterating through all of the addresses.

By replacing 2018 with %Year% and LOC2018-0027 with %LocNo% I was hoping to be able to pass different year and locno values into the iterator. I'm assuming the error has to do with %Year% and %LocNo%.

Thanks

0 Kudos
DanPatterson_Retired
MVP Emeritus

Chris I think that was my point... even if you were allowed to use an iterator to replace portions of the path and filename, you would have to have appropriately named ones in the folder for the iterator to find.  You are now treading into an area where a few lines of code could save you days of grief.  At worse, why not let the user select a new file by making it a parameter in the model.  You have to weigh the real savings that iterating by changing a file name... perhaps, you should just have a folder selected, then iterate through the csv files that are found in there.  it would be a lot quicker and cleaner

0 Kudos
curtvprice
MVP Esteemed Contributor

The issue is that the model will not validate until the values are populated.  You may be able to get the model to validate by right-click/Run GetLocNoAndYear.

I agree with Dan that this is fairly convoluted and you might have better luck with IterateFiles to get a list of .csv's and extracting the LocNo and Year from the file name (if you need it to name the outputs).

0 Kudos
ChrisHolmes
Occasional Contributor III

Thanks Dan and Curtis. Think I'm going to give some more thought to the process. Probably a better way of I look at it.

Thanks!

0 Kudos
ChrisHolmes
Occasional Contributor III

Also, the locno and year is needed only to determine the network folder where the csv file is.

0 Kudos
curtvprice
MVP Esteemed Contributor

I think what we are suggesting is iterate files recursive on a path above your csv files (like: O:\plan\luam\1p2007) and then extract the year locno values (if you need them, for example, to name an output file) from the input file name using the Calculate Value tool. Maybe you are understanding this already, but thought I'd spell it out.

0 Kudos
ChrisDonohue__GISP
MVP Alum

More of a longshot, but I'll throw it out there in case the issue is unresolved.  Something I noticed which may be tripping things up is the use of a restricted character in your file path.  Note the hyphen symbol in the last folder before the csv.  While not always a game-stopper, there are several processes in ArcGIS which trip up when fed a file located in a folder with a restricted character.  So if things are still not working, try renaming that folder to see if it clears things up.  For example, an underscore is acceptable in ArcGIS, so can be used instead of the hyphen.

Current:

O:\plan\luam\1p2007\2018\LOC2018-0027\addresses.csv

Better:

O:\plan\luam\1p2007\2018\LOC2018_0027\addresses.csv

Chris Donohue, GISP