Message-ID: <CAM_vjukZ_F8d-g1gdG8R9pRdim-4q0RR8tvzjGt-RN4n7CqkTg@mail.gmail.com>
Date: 2011-10-03T20:06:42Z
From: Sarah Goslee
Subject: read .csv from web from password protected site
In-Reply-To: <F0C3E401D2C72C4AAE9B02C742D6AB230BA42909@KFOCEX1.kfoc.local>
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 at 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 at 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