-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import directory #149
Import directory #149
Conversation
R/import_directory.R
Outdated
return(data.table::rbindlist(data)) | ||
}, | ||
error = function(e){ | ||
warning("Error is likely due to the presence of integer64 columns which cannot be coerced in the data.table's merge. To fix this pass the argument integer64=\"character\" to import_directory") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very special case where data.table
throws an error when using rbind
with integer64 columns as per their discussion. Arguably this trycatch block could be removed and the function allowed to fail to avoid returning either a data.frame or a list
A couple of reactions:
import_list(c("file1.csv", "file2.csv"), rbind = TRUE) which would call |
Apologies, I've corrected the tests. I agree that it mightn't warrant an entirely new function. It would be easy enough to add the two features (default behaviour to For default behaviour I'm referring to choosing a pattern based on the most common file extension for that directory. For example a scenario where a folder contains a README.txt or similar that should be ignored among 10 CSV files. |
Another idea is a handler for within
See ruaridhw/rio@58c190c and if it seems useful I can submit a separate PR |
Just a note that I implemented an |
Sounds great! Regarding my comment above, would either of those features suit Couple of illustrations:
|
I like I'm not sure about making decisions about merging - that seems like more than what rio is supposed to do. |
Which merging decision? I'm imagining a try-catch in case one of the |
@ruaridhw Ah, I misunderstood. Yes, I try catch on the call to |
I've implemented this in 433a4bc |
Love it! |
Hi Thomas,
Huge fan of the package! Thought I would add a function I've been using that is very similar to an idea that was suggested in #141. Obviously you've added
import_list
since that issue but this may be of some use if not absorbed intoimport_list
itself as a special case.Use Case:
Provides a simple wrapper over
import_list
for the case where a directory of files is to be loaded. Handles the expansion of files in the path and merging the list of data.frames.