Current location - Education and Training Encyclopedia - Resume - Import files in folders in batches with R language.
Import files in folders in batches with R language.
# Batch read electronic certificate files in folders.

The file name & lt-list.files ("d: \ \ work \ \190304 \ \ electronic certificate").

Path? & lt-c ("d: \ \ work \ \190304 \ \ electronic certificate \ \").

For (ii in1:length (file name)) (

? Name & lt-gsub (". Csv ","",file name [i])

? Assign (name,

read.csv(paste0(path,file_names[ 1]),

? header = TRUE,stringsAsFactors = FALSE))

}

bd _ mob0 & lt- data.frame()

? BD _ mob 1 & lt; - data.frame()

? For (ii in1:length (file name)) (

excel _ path & lt- paste0(path 1,file_names[i])?

Sheet name & lt-Excel _ Sheets (Excel _ Path) [6]?

bd _ mob0 & lt- cbind(read_excel(excel_path,sheet = sheet_name,skip =3),

? Account period = substr (file _ names [I],18,25)) # Add account period.

BD _ mob 1 & lt; - rbind(bd_mob 1,bd_mob0)

? }