0

Working to create a script which iterates over a set of CSV files and then joins to a ZIP file. Once that is completed, it goes through to Select by Attribute to ensure we are looking only at true values and not null.

enter image description here

I have the model written and it works well on the first pass, but when it comes to the next file it fails because the Select Layer by Attribute is looking for the previous filename. How can I pass the filename as a variable? Is this possible?

I have referenced the below article without any luck in having it work either.

https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/modelbuilder/inline-variable-substitution.htm

2
  • Not sure but I think your variable should be enclosed between quote and the slash and first % are not necessary, so try : '%NAME%'&'.csv.REV_SUB_TOTAL' IS NOT NULL
    – J.R
    Sep 29, 2023 at 14:51
  • I had tried that first as you can typically do %Name% or whatever the variable might be but from what I read you couldn't do that. I changed it back and I looked at the log a bit closer and it does carry it over but it still fails <pre> Executing (Select Layer By Attribute): SelectLayerByAttribute zip_poly "New selection" "DATA_JD_SAMPLE_DFW_GIS &'.csv.REV_SUB_TOTAL' IS NOT NULL" NON_INVERT ERROR 000358: Invalid expression Failed to execute (Select Layer By Attribute). Failed at Friday, September 29, 2023 2:39:42 P
    – John D
    Sep 29, 2023 at 18:57

1 Answer 1

0

I am not sure why I didn't think of this sooner. So I was able to get the %Variable% working as it should, but then I couldn't get the second half working such as '.csv.REV_SUB_TOTAL'

I added it as its own Variable called %String% and then changed my SQL statement to %Name%%String% IS NOT NULL and it worked!

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.