[R] read .csv from web from password protected site
Sarah Goslee
sarah.goslee at gmail.com
Mon Oct 3 22:06:42 CEST 2011
Hi,
I've assumed that you meant to send this to the R-help list, and not just me.
On Mon, Oct 3, 2011 at 3:54 PM, Mike Pfeiff <MikeP at kfoc.net> wrote:
> Sarah, Thanks for the suggestion. Although, read.table("http://userid:password@my.url/file.csv") did not work as it returned the following:
>
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") : unable to resolve 'userid'
>
> (where 'usesid is my actual userid)
>
> I've tried the following RCurl commands...
>
> myURL ="http://www.frontierweather.com/degreedays/L15N15PowerRegionAverages_10weeks.txt"
> h=getURL(myURL, userpw = "userid:passwod", followlocation=TRUE)
> test=read.table(h,header=TRUE,sep=",")
>
> ..and I can't get the data to read and get the following errors:
>
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") : unable to resolve 'userid'
>
> I'm at a total loss. Any assistance anyone could provide would be greatly appreciated.
You can get to the file using your web browser and that
userid/password combo, right?
Do you have to go through a dialog box? Press a button to login? Any
of those have the potential to
complicate the task.
If so, you'll need to work through the Forms section at
http://www.omegahat.org/RCurl/philosophy.html
Sarah
>
>
> -----Original Message-----
> From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
> Sent: Monday, October 03, 2011 2:26 PM
> To: Mike Pfeiff
> Cc: r-help at r-project.org
> Subject: Re: [R] read .csv from web from password protected site
>
> 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