当名称每天更改时,如何在R中上传文件

发布于 2025-02-06 14:05:54 字数 190 浏览 2 评论 0原文

我有一个需要每天上传的文件,文件名mis_01_10062022.xlsx。每天MIS_01 _文件名的一部分是常数日期零件 - 10062022日期更改。我如何每天上传该文件,每天选择它?是否可以通过仅提及文件名为mis_01 _*来选择文件。

I have a file that needs to be uploaded each day, file name MIS_01_10062022.xlsx. Each day MIS_01_ part of the file name is constant the date part - 10062022 changes due to date. How can I upload this file with out selecting it each day? Is it possible to select file by just mentioning the file name as MIS_01_*.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨曦慕雪 2025-02-13 14:05:54

这是您可以尝试的策略:

  • 列出可能引起的所有目录中的所有内容,例如a< -list.files(atterat =“ mis_01_”)
  • 保存所有文件信息(例如当创建文件时)在第二个变量中,例如,通过b< -file.info(a)
  • 使用此dataframe的“ mtime”列查找最新文件,例如,fiva 最新> fimate_file_index< -which.max(b $ mtime)。这将返回最新文件的索引,您可以通过最新_FILE_NAME< -a [festment_file_index]再次在初始变量A中访问该索引。

Here is a strategy of what you could try:

  • List all the in the directory that might be of interest, e.g. via a<-list.files(pattern="MIS_01_")
  • Save all file informations (e.g. when the files were created) in a second variable, e.g. via b<-file.info(a)
  • Find the latest file using the "mtime" column of this dataframe, e.g. via latest_file_index<-which.max(b$mtime) . This will return the index of the newest file, which you can again access in your initial variable a, via latest_file_name<-a[latest_file_index]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文