Here is a very simple (and "raw") example for reading a file using reticulate
and the Python built-in functions.
The content of myfile.txt
is:
ds y
"2017-05-23 08:07:00" 21.16641
"2017-05-23 08:07:10" 16.79345
"2017-05-23 08:07:20" 16.40846
"2017-05-23 08:07:30" 16.24653
"2017-05-23 08:07:40" 16.14694
"2017-05-23 08:07:50" 15.89552
and the code to read the file is:
library(reticulate)
funcs <- import_builtins()
fl <- funcs$open("myfile.txt", "r")
txt <- fl$readlines()
fl$close()
cat(txt)
# ds y
# "2017-05-23 08:07:00" 21.16641
# "2017-05-23 08:07:10" 16.79345
# "2017-05-23 08:07:20" 16.40846
# "2017-05-23 08:07:30" 16.24653
# "2017-05-23 08:07:40" 16.14694
# "2017-05-23 08:07:50" 15.89552
An alternative solution using the built-in file
function is:
fl <- funcs$open("myfile.txt", "r")
txt <- funcs$file$readlines(fl)
fl$close()