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:
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?
-
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.FelixIP– FelixIP2018年09月26日 21:12:57 +00:00Commented 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.user2856– user28562018年09月26日 23:58:09 +00:00Commented 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.Waterman– Waterman2018年09月27日 00:54:30 +00:00Commented Sep 27, 2018 at 0:54
2 Answers 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:
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.
Explore related questions
See similar questions with these tags.