读取文件名称中包含每日日期的文件 [英] Read file with daily date in the file name

查看:182
本文介绍了读取文件名称中包含每日日期的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每天我都会收到一个包含每日日期的文件,例如:res_20161216.csv

Every day I receive a file with the daily date in it, for instance: res_20161216.csv

我不知道如何自动每天读取其中包含每日日期的文件.

I have no idea how to automatically read every day a file with the daily date in it.

任何帮助将不胜感激!

谢谢

推荐答案

如果与要读取的文件位于同一工作目录中,则文件名如下.否则,您将需要使用getwd()

If you're in the same working directory as the files to be read, then the name of file is as follows. Else you will need to check what your working directory is using getwd()

nameOfFile <- paste0("res_", format(Sys.Date(), "%Y%m%d"),".csv")
data <- read.csv(nameOfFile)

这篇关于读取文件名称中包含每日日期的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆