library(xlsx)
lapply(files.to.read, function(f) {
df = read.xlsx(f, sheetName = 'Sheet8')
write.csv(df, gsub("xlsx", "csv", f), row.names=FALSE)
})
我正在将xlsx转换为csv,并希望
答案 0 :(得分:1)
像这样吗?
代码
files <- list.files(path = "./", pattern = "*.xlsx$", recursive = FALSE, full.names = TRUE)
sheet_to_read <- c( 8, 9, 10 )
library( readxl )
for( excelsheet in files) {
for (sheet in sheet_to_read) {
temp <- read_excel( path = excelsheet, sheet = sheet)
write.csv( temp, file = paste0( "./", gsub("./", "", excelsheet), "-sheet", sheet,".csv") )
}
}
结果