I have a folder with few hundred CSV files. What would be the easiest way to convert these to XLS format using R?
(Yes, I know CSV is Excel-compatible but I still have good reason to convert them.)
Use the package xlsReadWrite to export to xls:
library(xlsReadWrite)
filenames <- list.files("[path_name]", pattern="*.csv", full.names=TRUE)
for(i in 1:length(filenames)){
a <- read.csv(filenames[i])
write.xls(a, paste("file",i,".xls", sep=""))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With