2

I have a script which downloads pdf's from various urls with R. All the files download with different file sizes but appear blank with the following error message:

"A file I/0 error has occurred".

Can anyone help? I have searched the internet for this error message and tried many fixes with no luck. I am using OS Windows 7 Professional.

My code with an example pdf link

pdflist <- "www.geologyontario.mndmf.gov.on.ca/mndmfiles/afri/Data/Imaging/41P11NW0005/41P11NW0005.Pdf"

for (url in pdflist) {
  download.file(url, destfile = basename(url))
}
Marycee
  • 149
  • 1
  • 11
  • can you share at least the first url of pdflist please. – user20650 Mar 27 '16 at 21:31
  • Agree need a specific example. But thanks for the code. Didn't know `basename` existed. Have been using a construction like: `sub("^.+/", "", temp)`. I have fewer errors with `download` from pkg:`downloader`. – IRTFM Mar 28 '16 at 03:20
  • 1
    Thanks for the feedback. I figured it out. The following works perfectly:`for (url in pdflist) { download.file(url, destfile=basename(url)), mode = "wb" }`. This is an example of a url `"www.geologyontario.mndmf.gov.on.ca/mndmfiles/afri/Data/Imaging/41P11NW0005/41P11NW0005.Pdf'"` – Marycee Mar 28 '16 at 17:57
  • Hi Kathy, thanks for responding. I have edited your question with the link. Hopefully your question can be reopened, so that you can post your solution - which may be useful for future users. Also., please can you edit your question with your operating system (Windows?) as his question / answer is likely to be OS dependent, – user20650 Mar 29 '16 at 21:05
  • 1
    Rather than just answering, maybe we can find some appropriate dupes? One suggestion: http://stackoverflow.com/q/9655361/903061 – Gregor Thomas Mar 30 '16 at 18:12
  • @Gregor, that does seems a dupe. However, I also couldn't download it on ubuntu. I had to change the method (to wget), rather than the mode. So there may be something else going on (idk) – user20650 Mar 30 '16 at 19:40

0 Answers0