我有多个日期的CSV文件,例如。日期示例
我想为csv文件中的每个日期下载多个zip文件。
在下面的特定示例中,日期指定为20151117。是否可以通过以下代码在csv中下载每个日期,也许可以通过在以下代码中包含csv文件来进行下载?
download.file("https://www.quandl.com/api/v3/databases/OSMV/download?download_type=20151117&api_key=my_api_key", destfile = "/Users/anders/Documents/Juni 2019/DATA/datatest.zip", mode="wb", method="libcurl")
我希望我的问题有道理。
谢谢
这是一个应该起作用的小循环:
df <- data.frame(all_dates = c("20150711","20160613"))
dates <- unique(df$all_dates) # create list of dates that you want
for (d in dates){ # each 'd' is one date
# create url to download from for each date
download.file(paste0("https://www.quandl.com/api/v3/databases/OSMV/download?download_type=", d, "&api_key=my_api_key",
# create destination file with date in the file name
destfile = paste0("/Users/anders/Documents/Juni 2019/DATA/datatest", d, ".zip",
mode="wb", method="libcurl"))
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句