[R] help - RE: Download.file problem
Dear R-helpers ... any thoughts on the below issue ... will help me complete a small project! Strange problem with download.file . for non existent URL an empty file is created but I am not able to delete the without shutting down R Example: download.file(http://test.com/test.txt,test.txt;) trying URL 'http://test.com/test.txt' Error in download.file(http://test.com/test.txt;, test.txt) : cannot open URL 'http://test.com/test.txt' In addition: Warning message: In download.file(http://test.com/test.txt;, test.txt) : cannot open: HTTP status was '404 Not Found' If you go to working directory through windows explorer, you can see the empty file test.txt but try deleteting the file and it says that the file is locked. I tried closeAllConnections() but of no use. Any suggestions? Thanks, S __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help - RE: Download.file problem
On 18/10/2010 8:34 PM, Santosh Srinivas wrote: Dear R-helpers ... any thoughts on the below issue ... will help me complete a small project! Strange problem with download.file . for non existent URL an empty file is created but I am not able to delete the without shutting down R Example: download.file(http://test.com/test.txt,test.txt;) trying URL 'http://test.com/test.txt' Error in download.file(http://test.com/test.txt;, test.txt) : cannot open URL 'http://test.com/test.txt' In addition: Warning message: In download.file(http://test.com/test.txt;, test.txt) : cannot open: HTTP status was '404 Not Found' If you go to working directory through windows explorer, you can see the empty file test.txt but try deleteting the file and it says that the file is locked. I tried closeAllConnections() but of no use. Any suggestions? Suggestion: Don't try to download a nonexistent file to a filename that you care about. It looks like a bug in download.file is leaving the file open; Windows won't let you delete open files. So you could download to tempfile() first to see if it works; if that fails, you'll be left with a junk file open, but it will be closed when R quits. If you want to help, you could look through the internal code to figure out why the file isn't being closed, and submit a patch. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help - RE: Download.file problem
On 18/10/2010 9:32 PM, Duncan Murdoch wrote: On 18/10/2010 8:34 PM, Santosh Srinivas wrote: Dear R-helpers ... any thoughts on the below issue ... will help me complete a small project! Strange problem with download.file . for non existent URL an empty file is created but I am not able to delete the without shutting down R Example: download.file(http://test.com/test.txt,test.txt;) trying URL 'http://test.com/test.txt' Error in download.file(http://test.com/test.txt;, test.txt) : cannot open URL 'http://test.com/test.txt' In addition: Warning message: In download.file(http://test.com/test.txt;, test.txt) : cannot open: HTTP status was '404 Not Found' If you go to working directory through windows explorer, you can see the empty file test.txt but try deleteting the file and it says that the file is locked. I tried closeAllConnections() but of no use. Any suggestions? Suggestion: Don't try to download a nonexistent file to a filename that you care about. It looks like a bug in download.file is leaving the file open; Windows won't let you delete open files. So you could download to tempfile() first to see if it works; if that fails, you'll be left with a junk file open, but it will be closed when R quits. If you want to help, you could look through the internal code to figure out why the file isn't being closed, and submit a patch. I've confirmed this is still a problem in R-devel and submitted a bug report. I may be able to take a look at it tomorrow. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.