Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #isi dengan path folder yang akan kita ubah file txt ke csv
- alamat <- setwd("path_folder")
- FILES <- list.files( pattern = ".txt")
- for (i in 1:length(FILES)) {
- input<-FILES[i]
- output <- paste0(gsub("\\.txt$", "", input), ".csv")
- print(paste("Processing the file:", input))
- data = read.delim(input, header = TRUE)
- write.table(data, file=output, sep=",", col.names=TRUE, row.names=FALSE)
- }
Advertisement
Add Comment
Please, Sign In to add comment