在 R 中将包含多个工作表的大型 Excel 电子表格转换为 .CSV 文件的最简单方法是什么?
请注意,我已经测试了 XLConnect 和 XLSX,发现我的 Excel 工作表导致其崩溃。因此,我专门寻找一种不使用 XLConnect 或 XLSX 包的解决方案。
最佳答案
这是一个写出所有工作表的循环:
require(gdata)
## install support for xlsx files
installXLSXsupport()
excelFile <- ("/full/path/to/excelFile.xlsx")
## note that the perl scripts that gdata uses do not cope well will tilde expansion
## on *nix machines. So use the full path.
numSheets <- sheetCount(excelFile, verbose=TRUE)
for ( i in 1:numSheets) {
mySheet <- read.xls(excelFile, sheet=i)
write.csv(mySheet, file=paste(i, "csv", sep="."), row.names=FALSE)
}
关于excel - 使用 R 将 Excel 电子表格保存为 .csv?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8188415/