open multiple folders and filter a perticular value

HI,
I have a folder called BSRESULT . BSRESULT has 1000 subfolders in it, each subfolder contains 5 different files including a ".csv" file. each CSV file conatains 10 columns and around 500 rows.

Is there a way in R to open each subfolder and read ".CSV" and check "x" column in .csv for perticular value and return all the subfolder names with perticular value ?

Thanks for the help :slight_smile:

Here is a sketch of one approach. It assumes each subfolder contains exactly one csv file.

DIRS <- list.dirs(path = "BSRESULT")
CSVresults <- vector("logical", length = length(DIRS))
for (i in seq_along(DIRS)) {
  Nm <- list.files(path = DIRS[i], pattern = "csv$", full.names = TRUE)
  tmp <- read.csv(Nm)
  CSVresults[i] <- any(tmp$NameOfColumn == "ParticularValue")
}
TargetNames <- DIRS[CSVresults]

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.