Goal:
- Import the newest file (.csv) from a local directory into R
Goal Details:
- A csv file is uploaded to a folder dail
-- readfile.R --
files <- file.info(list.files(directory))
read.csv(rownames(files)[order(files$mtime)][nrow(files)])
I'd put the above script in a cron job that runs every morning at a time when the file for the day will have been written. The below crontab runs it every morning at 8am.
-- in crontab --
0 8 * * * Rscript readfile.R
Read more about cron here.