I am attempting to use RStudio to automate data freshness in an Excel document, but am new to coding and am having trouble.
Here's the scenario:
Each morning, I get a .txt file with a unique name (same information) deposited into the same folder. It does not overwrite the previous day's .txt file, it simply creates a new one.
I am hoping to use RStudio to automatically read the most recent .txt file from the folder, convert it to .xlsx, and have it update/overwrite an existing .xlsx file. This .xlsx file will serve as the basis for a dashboard, so it's important that the same .xlsx file is getting the new information from each day's .txt file.
Again, I'm very new to coding, so I don't have the most educated guess as to how this would be coded, but below is my best starting attempt:
require(readtext)
require(dplyr)
require(eeptools)
#Set Working Directory
setwd("G:\\My Drive\\Dashboards\\Text Files")
#Read latest text file
data_files <- file.info(Sys.glob("*.txt"))
row.names(data_files)[which.max(data_files[["ctime"]])]
Does anybody know exactly how I would have to code this?
Thank you in advance for your help. I greatly appreciate it!