[R] RODBC / odbcConnectExcel Issue
James W. MacDonald
jmacdon at med.umich.edu
Fri Apr 4 15:18:45 CEST 2008
Hi Vishal,
Vishal Belsare wrote:
> Can someone throw light on the following problem I am having with RODBC?
> There's an Excel file I am trying to read from, it has one sheet named
> 'nameclass'.
>
> Thanks in anticipation.
>
>
> Vishal Belsare
>
>
>> library(RODBC)
>> con = odbcConnectExcel(file.choose())
>> tbls <- sqlTables(con)
>> tbls
> TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS
> 1 T:\\data\\in\\nameclass <NA> nameclass$ SYSTEM TABLE <NA>
>
>> qry = paste("SELECT * FROM '",tbls$TABLE_NAME[1],"'",sep="")
>> result = sqlQuery(con,qry)
>> result
> [1] "[RODBC] ERROR: Could not SQLExecDirect"
>
> [2] "42000 -3506 [Microsoft][ODBC Excel Driver] Syntax error in FROM
> clause."
You want your table name to be wrapped in []. In this case the query
should be
SELECT * FROM [nameclass$]
Best,
Jim
>
> [[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.
--
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623
More information about the R-help
mailing list