Select to view content in your preferred language

Modelbuilder - Fill in list of values from excel

327
1
03-30-2023 09:29 PM
Labels (2)
slgissolutions
New Contributor

Hi all,

I'm trying to find a way that I can import a list of values that I have in an excel file into a "List of Values" string variable in my model? I'm trying to avoid having to type each one in manually.

Tags (1)
0 Kudos
1 Reply
DavidSolari
Frequent Contributor

Use "Excel to Table" to load the data into a table, then "Calculate Value" with some Python cursors to join the column values into one big string. Something like this for the code block:

 

def get_list(table):
    return ";".join(str(x[0]) for x in arcpy.da.SearchCursor(table, "My_Field_Name"))

 

and then you can call the function like get_list("%output_table%"), replacing the variable with whatever the name of your output table is in modelbuilder.

0 Kudos