solares@unsl.edu.ar
2004-Apr-02 15:47 UTC
[R] convert excell file to text with RODBC package
Hi, i can convert excell to list in R with package RODBC ()but i don't understand 2 mistake 1) Don't read the last row of the table excell 2) Don' t take the hours My excell file call prueba4.xls and have the following rows: where prueba4.xls was make in excell (office xp) and have one spreadsheet call "Hoja1", you see each rows of she: D??a Hora col1 col2 col3 col4 col5 col6 col7 col8 15/12/2003 12:14:59 217 2760 8,2 35 79,6 86,4 15/12/2003 12:15:00 217 2764 8,2 35 79,6 86,4 15/12/2003 12:15:01 217 2758 8,3 35 79,6 86,4 15/12/2003 12:15:02 217 2760 8,3 35 79,6 86,4 15/12/2003 12:15:03 217 2755 8,3 35 79,6 86,4 15/12/2003 12:15:04 217 2766 8,3 35 79,6 86,4 15/12/2003 12:15:05 217,1 2766 8,3 35,1 79,6 86,4 15/12/2003 12:15:06 217,1 2758 8,3 35,1 79,6 86,4 15/12/2003 12:15:07 217,1 2768 8,3 35,1 79,6 86,4 My code (i use the R 1.7.1 for windows xp) is the following: library(RODBC)> canal<-odbcConnectExcel("c:/prueba4.xls") > tablas<-sqlTables(canal) > tablasTABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS 1 c:\\prueba4 <NA> Hoja1$ SYSTEM TABLE <NA> 2 c:\\prueba4 <NA> Hoja2$ SYSTEM TABLE <NA> 3 c:\\prueba4 <NA> Hoja3$ SYSTEM TABLE <NA>> tbl<-sqlFetch(canal,substr(tablas[1,3],1,nchar(tablas[1,3])-1)) > tbl[1]D??a 1 2003-12-15 00:00:00 2 2003-12-15 00:00:00 3 2003-12-15 00:00:00 4 2003-12-15 00:00:00 5 2003-12-15 00:00:00 6 2003-12-15 00:00:00 7 2003-12-15 00:00:00 8 2003-12-15 00:00:00 9 2003-12-15 00:00:00 ??Which is the mistake?. And the second question is the command odbcFechRows() don't work, for example if write tbl<-odbcFetchRows(canal) in place of sqlFetch result a error stat = -1 and the list is NULL odbcGetErrMsg return No results available. Thank Ruben
Prof Brian Ripley
2004-Apr-02 16:04 UTC
[R] convert excell file to text with RODBC package
On Fri, 2 Apr 2004 solares at unsl.edu.ar wrote:> And the second question is the command odbcFechRows() don't work,That is not a question, that is an assertion! There is no such function, and I presume you mean odbcFetchRows().> for example if write > tbl<-odbcFetchRows(canal) in place of sqlFetch result a error > stat = -1 and the list is NULL > odbcGetErrMsg return No results available. Thank RubenIf you used odbcFetchRows(), it worked exactly as documented. Please do read the help pages! Hint: you had no `pending rowset'. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595