I have a script called DataRetrieval.py
. This script connects to an internal database, retrieves data and writes that data to an Excel file. This script imports the following:
a) a utils.py
helper module that contains several functions
b) a DataRetrieval.cfg
configuration file (which contains all of the login information and SQL queries that the DataRetrieval.py
script needs)
The DataRetrieval.py
script takes the following 3 command line arguments:
DataRetrieval.py DataRetrieval.cfg 03/01/20
(the script itself, the configuration file, and a start date)
I would like to use the Reticulate
package in R to:
I was thinking about using the source_python()
function, but I don't think it allows for multiple positional arguments. The error message returns:
> source_python("DataRetrieval.py")
Error in py_run_file_impl(file, local, convert) : SystemExit: 2
usage: python.exe [-h] [-e ENDDATE] config startDate
python.exe: error: the following arguments are required: config, startDate
What is the best way to use the Reticulate
package to call these 3 command line arguments? Perhaps a single .py
file that encapsulates each of the 3 arguments above?
Thanks!
EDIT: I solved this problem by creating a .py file named retrieve.py
and passing that file to the source_python()
Reticulate function. The retrieve.py
file reads as follows:
import os
os.system('python DataRetrieval.py DataRetrieval.cfg 02/01/20')