s*****d 发帖数: 2667 | 1 read.table 读不进来,用了RODBC package
> library(RODBC)
> channel <- odbcConnectExcel("D:datadata.xls")
> mydata <- sqlFetch(channel, "Sheet1")
> odbcClose(channel)
> mydata
显示
[1] "HY000 -5038 [Microsoft][ODBC Excel Driver] The connection for viewing
your linked Microsoft Excel worksheet was lost."
[2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM [Sheet1$]'"
用gdata好象更麻烦
同样的数据 txt file 就能读进来
怎么解决, 请教一下达人。谢谢 |
l******n 发帖数: 9344 | 2 建议弄成txt or cvs再读
【在 s*****d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : read.table 读不进来,用了RODBC package : > library(RODBC) : > channel <- odbcConnectExcel("D:datadata.xls") : > mydata <- sqlFetch(channel, "Sheet1") : > odbcClose(channel) : > mydata : 显示 : [1] "HY000 -5038 [Microsoft][ODBC Excel Driver] The connection for viewing : your linked Microsoft Excel worksheet was lost." : [2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM [Sheet1$]'"
|
t*****w 发帖数: 254 | 3 it is an easy and practical idea. Don't bother excel.
【在 l******n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 建议弄成txt or cvs再读 : :
|
a***d 发帖数: 336 | 4 csv has only one tab, xls can have many...
I used read.xls from gdata. sometimes it works sometimes doesn't..:(
【在 t*****w 的大作中提到】![](/moin_static193/solenoid/img/up.png) : it is an easy and practical idea. Don't bother excel.
|
q*******l 发帖数: 36 | 5 用这个试试:
require(xlsx)
read.xlsx {xlsx}
read.xlsx(file, sheetIndex, sheetName=NULL, rowIndex=NULL,
startRow=NULL, endRow=NULL, colIndex=NULL,
as.data.frame=TRUE, header=TRUE, colClasses=NA,
keepFormulas=FALSE, encoding="unknown", ...)
【在 s*****d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : read.table 读不进来,用了RODBC package : > library(RODBC) : > channel <- odbcConnectExcel("D:datadata.xls") : > mydata <- sqlFetch(channel, "Sheet1") : > odbcClose(channel) : > mydata : 显示 : [1] "HY000 -5038 [Microsoft][ODBC Excel Driver] The connection for viewing : your linked Microsoft Excel worksheet was lost." : [2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM [Sheet1$]'"
|
l******n 发帖数: 9344 | 6 you can write vba to save xls to csv tab by tab
I do not think your boss would like to see when it does not work ...
【在 a***d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : csv has only one tab, xls can have many... : I used read.xls from gdata. sometimes it works sometimes doesn't..:(
|
a***d 发帖数: 336 | 7 thanks, will try it next time.
【在 l******n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : you can write vba to save xls to csv tab by tab : I do not think your boss would like to see when it does not work ...
|