[R]文件处理


  • 合并csv
path <- 'E:\\Data\\combine'
setwd(path)
dir(path)
name_table <- as.data.frame(dir(),stringsAsFactors = F) 
initial_data <-
  read.table(paste0(name_table$`dir()`[1]),
             header = TRUE,
             sep = ",")
for(k in 2:length(name_table$`dir()`))
{
    temp_data <-
      read.table(paste0(name_table$`dir()`[k]),
                 header = TRUE,
                 sep = ",")
    
    initial_data <- rbind(initial_data,temp_data)
}

  • 批量修改文件名(ps:修改锁屏壁纸到本地)
path <- 'C:\\Users\\HOHO\\AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets'
setwd(path)
dir(path)
fl <- as.data.frame(dir(),stringsAsFactors = F) 
fl_2 <- paste0(fl$`dir()`,".jpg")
fl <- dir()
fl_2 <- as.character(unlist(fl_2))
file.rename(fl, fl_2)
上一篇:AsyncTask异步任务


下一篇:Android编程规范