Download multiple excel files linked through urls in R

0 votes

I have a list containing hundreds of URLs directly linking to .xlsx files for a download:

list <- c("https://ec.europa.eu/consumers/consumers_safety/safety_products/rapex/alerts/?event=main.weeklyReport.Excel&web_report_id=980", 
          "https://ec.europa.eu/consumers/consumers_safety/safety_products/rapex/alerts/?event=main.weeklyReport.Excel&web_report_id=981", 
          "https://ec.europa.eu/consumers/consumers_safety/safety_products/rapex/alerts/?event=main.weeklyReport.Excel&web_report_id=990")

To download everything in the list, I created a loop:

for (url in list) {
  download.file(url, destfile = "Rapex-Publication.xlsx", mode="wb")
}

However, it only downloads the first file and not the rest. My guess is that the program is overwriting the same destfile. What would I have to do to circumvent this issue?

Sep 22 in Others by Kithuzzz
• 12,240 points
11 views

1 answer to this question.

0 votes

Try something along the lines of:

for (i in 1:length(list)) {
  download.file(list[i], destfile = paste0("Rapex-Publication-", i, ".xlsx"),  mode="wb")
}
answered Sep 23 by narikkadan
• 20,880 points

Related Questions In Others

0 votes
1 answer

How to open .xlsx files in MS Excel from VS Code?

Hello, to open xlxs files, or files ...READ MORE

answered Feb 17 in Others by gaurav
• 18,960 points
49 views
0 votes
0 answers

Importing Excel files into R, xlsx or xls

Please can someone help me on the ...READ MORE

Jun 13 in Others by Avinash
• 1,260 points
19 views
0 votes
1 answer
0 votes
0 answers

SharePoint - Excel Online - Edit in Excel and Edit in Browser multiple users

I have created an excel document in ...READ MORE

1 hour ago in Others by Kithuzzz
• 12,240 points
6 views
0 votes
1 answer

Excel, How to split cells by comma delimiter into new cells

The Excel manual method: choose Text to Column ...READ MORE

answered 17 hours ago in Others by narikkadan
• 20,880 points
13 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
452 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
494 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
4,453 views
0 votes
1 answer

Print chosen worksheets in excel files to pdf in python

In the simplest form: import win32com.client o = win32com.client.Dispatch("Excel.Application") o.Visible ...READ MORE

answered Sep 24 in Others by narikkadan
• 20,880 points
22 views
0 votes
1 answer

An error for excel download in Firefox for JMeter script recording

You shouldn't just copy and paste configuration ...READ MORE

answered 4 days ago in Others by narikkadan
• 20,880 points
40 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP