[R] Re ading multiple Excel 2007 files with a loop

Mark W. Miller mark_wayne_miller at yahoo.com
Wed Nov 18 22:14:05 CET 2009


Thank you for all of the responses.  They were all very helpful.  The best
response came from a gentleman at Berkeley who suggested I change the
channel statement to that used below:
Mark Miller

Gainesville, Florida




library(RODBC)


setwd("U:/test folder")


fname <- list.files(pattern=".\\.xlsx", full.names = FALSE, recursive =
TRUE, ignore.case = TRUE)

z <- length(fname)

print(z)


for (sp in 1:z) {

channel <- odbcDriverConnect(paste("DRIVER=Microsoft Excel Driver (*.xls,
*.xlsx, *.xlsm, *.xlsb); DBQ=U:\\test folder\\",fname[sp],";
ReadOnly=False",sep=''))
 
sqlTables(channel)

my.data <- sqlFetch(channel, "Sheet1")

print(my.data)

odbcClose(channel)
}


-- 
View this message in context: http://old.nabble.com/Reading-multiple-Excel-2007-files-with-a-loop-tp26414828p26415864.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list