Run Script - Python
Does anyone know how the "arguments" in the 'Run Script' command are passed through to Python? Currenty my first argument is the specific script file and workiva is able to run it but I am getting an error where my script is asking for input(), or if I remove the input I am unsure of how to pass the variables needed in my script from workiva to my python script.
For example, I have a python script that runs a query and exports it to csv with data cleaned up. I need to pass through to the script 2 variables/arguments. Month as an integer (ex. 1 for the month of January) and Year as an integer (2024...)
I cannot seem to figure out how to pass these arguments into my script using the 'Run Script' command. If I need to use another strategy in python besides requesting input() please let me know.
-
In case anyone runs into the same issue, I figured out how to pass the arguments through. You need to use this format and eliminate your input() functions in python if you have them and use this instead.
sys.argv[0] will be your actual script and then 1,2,3,etc. are the arguments you want to pass in as variables.
I also attached what I input as arguments in the chain to get it to run. Month 13 for us simply includes year end adjustments.
if len(sys.argv) > 1:
month = sys.argv[1]
year = sys.argv[2]0Please sign in to leave a comment.
Comments
1 comment