'Splitting Excel workbook with 50 Sheets into CSV files IN R
I am a very basic R user and not into loops or advanced R. Challenge I am facing with an Excel Workbook with 50 worksheets and each worksheet is comprising of 1 Million rows. Loading into R this huge workbook of appx 5GB is not getting possible. I am looking forward for a fast method in R to get this workbook split into multiple CSVs of a single consolidated one
Tried to search lot of solutions and system is not responding for hours.
Please help me out of this
Solution 1:[1]
What about a function like this?
library(readxl)
csv_saver <- function(sheet_number){
csv <- read_xlsx(path = "yr_file_name.xlsx", sheet = sheet_number)
write.csv(csv, file = paste0("sheet_",sheet_number,".csv"))
}
lapply(1:50, csv_saver)
This reads in the sheet number specified by the variable sheet_number as a dataframe and then writes the dataframe out as csv file. You then apply that function to the vector of all the numbers between 1 and 50
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Russ |
