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?

  • 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 Sep 26 '18 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 Sep 26 '18 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 Sep 27 '18 at 0:54
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

| improve this answer | |
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.

| 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.