I have a python script that has kindly been developed by one of our architects here. I would like to execute it in R
using the Reticulate
package. The script acts like an API to one of our systems. I call it on my machine providing it with a number and it spits out a JSON file for me.
I can see from looking at the documentation that it is possible to run the script using py_run_file(file)
. I am able to use this to run the script but it fails when I add arguments saying it does not know where the file is. It all works perfectly via the command prompt and the file can be found when i don't include the arguments.
I am aware I could just wrap the cmd prompt in R to execute the script via python but was wondering if its possible to just submit the command to Reticulate
and get back the results. Below is a pseudo-code example
library(reticulate)
file = 'C:/Users/foo/Documents/util/account_number.py -n 9998877'
py_run_file(file)
Error in py_run_file_impl(file, local, convert) : Unable to open file 'C:/Users/foo/Documents/util/account_number.py -n 9998877' (does it exist?)
Thank you very much for your help