r - 可以使用 csv 文件在 url 中下载多个 zip 文件吗?
问题描述
我有一个包含多个日期的 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"))
}
推荐阅读
- python - Django: For each loop with counter that loads queryset in small sets
- c# - 与 Salesforce 相比,C# 的 HMAC SHA512 值太短?
- python - 如何使用多个东西来检查 else 语句?
- sed - 使用 sed 混合大小写标签
- scala - 正常分布的 Spark 函数 (norm.dist)
- azure-devops - 是否可以基于变量创建额外的管道步骤?
- go - Go GORM Preload & Select only items 匹配预加载表条件
- react-native - GesturesEnabled: false 在 React Native 中不起作用
- javascript - React Native - 异步等待的问题
- macos - CoreAnalytics::Client / FrameworkConfiguration::init 内部的神秘崩溃