Created
July 2, 2020 13:47
-
-
Save przmv/9e55d46ed5410e73e1f283a40e575158 to your computer and use it in GitHub Desktop.
Convert all xls[x] files in the current directory to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
library(readxl) | |
pattern <- ".xls[x]?$" | |
# Create a vector of Excel files to read | |
files_to_read = list.files(pattern=pattern) | |
# Read each file and write it to CSV | |
lapply(files_to_read, function(f) { | |
df <- read_excel(f) | |
write.csv(df, gsub(pattern, ".csv", f), row.names=FALSE) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment