I created a model builder which produce a summary statistics table, and a script tool which use this table in input, and tranpose it the way I whish to display results. I then want to join the reformated table from script tool, to a layer.
The issue is that the output of the script tool is not created, and I don't understand why.
JulietteLapeyre_2-1669046344486.png
1) summary statistics table created in the model builder
| id | disruptive_element | disruptive_surface |
| 29 | cp | 800 |
| 29 | rb | 500 |
| 29 | aut | 300 |
| 30 | cp | 400 |
2) transposed table, produced in the script tool
| id | cp | rb | aut |
| 29 | 800 | 500 | 400 |
| 30 | 400 | 0 | 0 |
I defined the input and output parameters in the script tool properties, and wrote the script in the execution tab.
JulietteLapeyre_0-1669046011935.png
JulietteLapeyre_1-1669046066652.png
At the end of the script, there are the following lines. the csv is saved, but the table is not created in the geodatabse.
# Set local variables
out_name = "outStats.csv"
saving_path = os.path.join(homeFolder, out_name)
pivot_df.to_csv(saving_path, sep=',', index=True)
arcpy.MakeTableView_management(in_table=saving_path, out_view='viewtemp')
outTab = arcpy.TableToTable_conversion('viewtemp', defaultGDB, 'tempTable')
arcpy.SetParameter(1, outTab)
3) Join the previous table to a polygon layer, which contains the ids
this step doesn't work yet
Solved! Go to Solution.
Hi Jeff,
yes it is correct. sys.argv[i] starts from 1, and Get/SetParameter[i] starts from 0.
It works now, I forgot to check 'add to display' in my model builder...
are the sys.args[i] indexing in your execution code correct? Should they be 0 and 1 perhaps?
Hi Jeff,
yes it is correct. sys.argv[i] starts from 1, and Get/SetParameter[i] starts from 0.
It works now, I forgot to check 'add to display' in my model builder...