My Python Script tool (ArcGIS Desktop 10.2) has two
The first parameter is populated by the
initializeParameters(self) module in the validation script which selects all CSVs in a particular folder. Obviously set to 'Input' and 'Multivalue = yes' It works fine.
The second parameter is populated by the
updateParameters(self) module in the validation script by:
1) taking one CSV at a time (from parameter 1), and according to the information in its name...
2) pulling the proper path + file name from a "settings" (dbf) table with which to populate the second parameter, which is 'Output' and obviously set to "Multivalue = yes'.
If I select multiple CSVs from Parameter 1 the "Target_FCs" list only has the first corresponding path + file name appended to it (again, via the "settings" (dbf) table as described in step 2, above).
There are no problems with the values from my "settingsTable" (e.g. "mypath").
Quite sure the issue is that the
for row in cursor line is only working the first time, just don't know why and how to make it work each time through the
for csv in CSVs.split(';') loop.
BTW - I can confirm that the
for csv in CSVs.split(';') loop is working correctly. If I choose 3 CSVs from Parameter 1, this loop is traveled 3 times, but the
for row in cursor is only traveled once.
Validation Code Snippet:
import arcpy import os def updateParameters(self): settingsTable = os.path.join(os.path.split(os.path.realpath(__file__)),"Settings_CSV_to_ASMAD_FC.dbf") cursor = arcpy.SearchCursor(settingsTable) Target_FCs =  CSVs = str(self.params.value) x = 0 if self.params.altered: for csv in CSVs.split(';'): if csv.upper().find("SMALLSITES") != -1: datatype = "SmallSites" elif csv.find("BIGSITES") != -1: datatype = "BigSites" if csv.upper().find("INACTIVE") != -1: activity = "Inactive" elif csv.upper().find("ACTIVE") != -1: activity = "Active" for row in cursor: myname = row.getValue("Name") mypath = row.getValue("Location") if myname == datatype + "_" + activity: Target_FCs.append(mypath) self.params.value = Target FCs return
CSV contents are not relevant to this question, only their names. Some names could be: "BIGSITES_ACTIVE.csv", "SMALLSITES_INACTIVE.csv", etc...
Settings Table looks like this:
Name Location BIGSITES_ACTIVE Q:\Data\Sites.gdb\BigSites_Active BIGSITES_INACTIVE Q:\Data\Sites.gdb\BigSites_Inactive SMALLSITES_ACTIVE Q:\Data\Sites.gdb\SmallSites_Active SMALLSITES_INACTIVE Q:\Data\Sites.gdb\SmallSites_Inactive
It's really just a lookup table to determine where the new FC (that is to be created from the CSV) is to be stored.