[R] read .csv from web from password protected site

Sarah Goslee sarah.goslee at gmail.com
Mon Oct 3 21:25:53 CEST 2011


Hi Mike,

On Mon, Oct 3, 2011 at 12:31 PM, Mike Pfeiff <MikeP at kfoc.net> wrote:
> I am very new to R and have been struggling trying to read a basic ".csv" file from a password protected site with the following code:
>
> myURL  ="http://www.frontierweather.com/degreedays/L15N15PowerRegionAverages_10weeks.txt"
> test2=read.table(url(myURL),header=TRUE,sep=",")


> A 'data.frame' is returned into the workspace, however it is not the data contained in the ".csv" file.   I think this occurs because the website where I am trying to retrieve the data is password protected.
>
> Is there a way to specify the username and password?


I'd try first
read.table("http://userid:password@my.url/file.csv"), which is the
standard way to do it (hint: try that form in your web browser and see
whether you can access the data), and if that doesn't work look into
the RCurl package. The list archives have a fair bit of information on
this topic.

Sarah


> Any guidance would be greatly appreciated.
>
> Sincerely,
>
> Mike
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list