1

I have a csv file with multiple dates, eg. Example of dates

I want to download multiple zip files for each date in the csv file.

In the specific example below the date is given as 20151117. Is there a way to download for each date in the csv instead, maybe by including the csv file in the code below?

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")

I hope my question make sense.

Thank you

Anders
  • 73
  • 7

1 Answers1

1

Here's a little loop that should work:

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"))
}
Zoey RW
  • 185
  • 1
  • 15