[Rd] RODBC bug or doc error in sqlFetch on xls files (PR#7354)

From: <gunter.berton_at_gene.com>
Date: Wed 10 Nov 2004 - 05:23:49 EST

R 2.0.0 patched under win2000. MS Office Excel 2003. ODBC Drivers?

This may not come as a surprise -- sqlFetch() (and perhaps other ?) appear not to handle table/worksheet names with spaces in them in Excel tables. I was not able to find documentation that specifically mentioned this, although the Help pages vaguely hinted that there might be difficulty with Excel's "peculiar handling" of table names. Anyway, here is a sequence of actions that illustrate the issue.

> library(RODBC)

## connect to Excel file using dialog box
> z<-odbcConnectExcel()

## List the tables: "Success Rates" is the only worksheet there, of course
> sqlTables(z)

                                                      TABLE_CAT TABLE_SCHEM
1 C:\\Documents and Settings\\bgunter\\My Documents\\LRPdatacln        <NA>
2 C:\\Documents and Settings\\bgunter\\My Documents\\LRPdatacln        <NA>
3 C:\\Documents and Settings\\bgunter\\My Documents\\LRPdatacln        <NA>
1             'Success Rates$'      TABLE    <NA>
2   'Success Rates$'Print_Area      TABLE    <NA>
3 'Success Rates$'Print_Titles      TABLE    <NA>

## The following give errors, although
## according to p.16 of manual, this should work:
> dat<-sqlFetch(z,"Success Rates")

Error in odbcTableExists(channel, sqtable) :

        Success Rates : table not found on channel

## This only seemed to work ...
> dat<-sqlFetch(z,"'Success Rates$'")

## But
> dat

[1] "[RODBC] ERROR: Could not SQLExecDirect"

[2] "37000 -1002 [Microsoft][ODBC Excel Driver] ''Success Rates$'$' is not a valid name. .. blah blah  

When I removed the space from the sheet name -- "SuccessRates" -- all worked smoothly as documented.


"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box

R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 10 05:38:21 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:01:17 EST