[R] Downloading Excel file & reading a range

Gabor Grothendieck ggrothendieck at gmail.com
Sat Jan 17 16:42:28 CET 2009


Actually sep = "," and header = TRUE are the defaults so its just

DF <- read.xls(v, pattern = "EWSB")


On Sat, Jan 17, 2009 at 9:57 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> Try this.  pattern = "EWSB" says to ignore everything in the file
> before the first line containing EWSB.  It then reads the
> remainder read.table style into data frame DF.
>
> library(gdata)
> v <- "http://www.statistics.gov.uk/elmr/01_09/downloads/Table1_07.xls"
> DF <- read.xls(v, pattern = "EWSB", sep = ",", header = TRUE)
>
>
>
> On Sat, Jan 17, 2009 at 9:40 AM, simeon duckworth
> <simeonduckworth at gmail.com> wrote:
>> I am trying to figure out a way to download an Excel file and then read a
>> range into R  - so that i can have a reasonably automated process.  I have
>> been trying to use the RODBC package, but with little success.  I suspect
>> that this isnt the right route
>>
>> Here is some code.  My aim is to read in the data starting in H69:H283 in
>> sheet 2.
>>
>> v<-"http://www.statistics.gov.uk/elmr/01_09/downloads/Table1_07.xls"
>> dest<-"C:/Data/onstest.xls"
>> download.file(url=v,destfile=dest,mode="wb")
>>
>> library(RODBC)
>> channel <-odbcConnectExcel(dest)
>> qry <- paste("SELECT * FROM '",tbls$TABLE_NAME[2],"'",sep="")
>> onstest <- sqlQuery(channel,qry)
>> close(channel)
>>
>> very grateful for any help
>>
>> simeon
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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.
>>
>




More information about the R-help mailing list