0

I do not know how to create a reproducible example of this issue since it would require access to a folder on my computer(if anyone has a suggestion I am fine to follow up). However, what I would like to do is upload a file in a folder without actually referencing the name but only referencing the order it appears in the file, and I would like to do it in R if possible(although python would be fine as well). I want to do this because the folder has 40 or so files and I need to format them all the same, but they all have different names.

In other words I want a code that would look something like this:

setwd(folder)

for(i in 1:number of files in folder){

upload file i

process file i

rbind(master file,file i)

}

Obviously this is not an actual code, but merely a framework, so I did not put it in the code framework on the site. The line I do not know how to do is the first line in the loop(download file i). Is it possible to do this, or do I need to download every file individually with their specified name?

Rajith Thennakoon
  • 3,604
  • 2
  • 12
  • 21
MathStudent
  • 115
  • 9

1 Answers1

1

I think you're looking for list.fles()

ff <- list.files()

for(i in seq_along(ff)){
  print(ff[i])
  read.csv(ff[i], ...) # etc

  ...

}
Edward
  • 9,369
  • 2
  • 10
  • 24