Guest User

Untitled

a guest
May 9th, 2018
1,563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.40 KB | None | 0 0
  1. #isi dengan path folder yang akan kita ubah file txt ke csv
  2. alamat <- setwd("path_folder")
  3.  
  4. FILES <- list.files( pattern = ".txt")
  5. for (i in 1:length(FILES)) {
  6.   input<-FILES[i]
  7.   output <- paste0(gsub("\\.txt$", "", input), ".csv")
  8.   print(paste("Processing the file:", input))
  9.   data = read.delim(input, header = TRUE)  
  10.   write.table(data, file=output, sep=",", col.names=TRUE, row.names=FALSE)
  11. }
Advertisement
Add Comment
Please, Sign In to add comment