0

Using Arc 10.2.2.

My script tool's interface has its first parameter populated by the following snippet of validation script:

 def initializeParameters(self):
 # Source Folder
 dir_f = r'Q:\GW\\EC1210WQAEH_QESEA\\CSSP_ATL\\Data\\CSSP_Web_Tools_Imports'
 csvs = [os.path.join(dir_f, f) for f in os.listdir(dir_f) if f.endswith('.csv')]
 self.params[0].filter.list = csvs

It populates the first parameter window with all the .csv files in the specified directory but for some reason it adds a final selection box and makes it checked.

Screen grab:

enter image description here

Every time I run the tool I must scroll to the bottom of the list and uncheck this box to make the red "X" (error message) go away and allow me to run the tool.

Why is this happening?

asked Sep 26, 2018 at 20:50
3
  • When dealing with cumbersome validation I found that why question is not efficient. Just try to find workaround. Perhaps remove last item, or change type of parameter to any. Commented Sep 26, 2018 at 21:12
  • Your code works as expected in ArcGIS 10.3.1. Are you manually setting anything as the filter list in the parameter (i.e not via validation)? Any file names with non-ascii characters in that folder? Try removing the double backslash from your path. Commented Sep 26, 2018 at 23:58
  • I believe I have the answer. For some reason there was a "schema.ini" file in the folder with all the other .csvs. Not sure why it was there. I certainly never created it (knowingly). Anyhow, once I deleted it the extra box has disappeared. I am surprised the "f.endswith('.csv')" wasn't smart enough to exclude the ".ini" file. Commented Sep 27, 2018 at 0:54

2 Answers 2

2

This is not the answer, but I thought I'll share my experience with parameter type ANY. @Luke statement is correct, it can't have Value List filter, but it can contain a list of values.

With some efforts in validation scripts you can do cool things, when using 'any' e.g. move items up and down. Screenshot below shows interface of my script dealing with reordering fields in feature class. This allows to reorder fields in place, i.e. without creation of yet another shapefile/class in database:

enter image description here

answered Sep 27, 2018 at 1:32
0
1

For some reason there was a "schema.ini" file in the folder with all the other .csvs. Not sure why it was there. I certainly never created it (knowingly).

Once I deleted it the extra box has disappeared, so problem solved, but I am still surprised the "f.endswith('.csv')" wasn't smart enough to exclude the ".ini" file.

answered Sep 27, 2018 at 1:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.