vroom with Purrr skip over error files


I've been using vroom now for loading files and it has been great. I read the post and using map instead of map_df to get the files is a great solution.

I am not sure why but there are occasions when some files will give me an error and vroom will stop.

Path = dir_ls(glob = "*2016*")**

Files = map(Path, ~vroom(.x, delim = ","))

The error message I got is Error in vroom_(file, delim = delim %||% col_types$delim, col_names = col_names, : ** embedded nul in string: 'A'

That's fine, I want it to move onto the next file - but when I wrap it,

Path = dir_ls(glob = "*2016*")

*Files = map(Path, ~possibly(vroom(.x, delim = ","), otherwise ="Error w File"))

possibly doesn't know what to do with a data frame.

I'm just looking for vroom to move onto the next file and flag the error one if that's possible.

Sorry about the formatting.

Generally if you are using vroom you would not use map at all. simply pass the names of all of the files directly to the vroom() call.

But the CRAN version of vroom does not support embedded nulls in files. The current development version of vroom does however (with a warning).

You give possibly a function to run, not output, e.g. this should return a list of the results as tibbles, and NULL if a file could not be read.

results <- purrr::map(path, possibly(function(x) vroom(x, delim = ","))

This topic was automatically closed 21 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.