0
votes

I want to read all csv-files in a directory into R and bind them together. I use vroom to read the files and map_dfr to apply the reader to all files and bind them together. This perfectly works for a few hundred files. However, I get the following error when applying it on 3000 files.

mapping error: Too many open files

My (simplified) pipe looks as follows:

library(vroom)
library(dplyr)

files <- list.files(path = "some_path", pattern = "*.csv", full.names = TRUE)

data_combined <- files %>%
   map_dfr(vroom)

The files are only approximately 100kb each, hence memory shouldn't be an issue. If someone came across this problem as well or has an idea of how to solve it, I would very much appreciate your help.

PS: The same error occurs when using fread or readr to read the files. The problem is obviously with purrr's map function.

Have you tried with couple of files insteead of the full file list i.e. files[1:2] %>% map(vroom) what does it output - akrun
@akrun Yes, that works perfectly. I can run it with files[1:500]. - Patrick Balada
Just wanted to check if it i duee to memory. So, you can subset only a couple of filse and test it - akrun
Yes, that works. Memory shouldn't be an issue I think. - Patrick Balada
if it works and it is only an issue when you read al the datasets, then memory would be an issue - akrun