-
Notifications
You must be signed in to change notification settings - Fork 25
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
Read file using Box file path #223
Comments
There is no support for read by path at the Box API level AKAIK.
Your wrapper is a handy way to get around it with boxr. If other boxers
find it useful, maybe it could be added as a helper.
…On Mon, Dec 13, 2021 at 5:20 PM rrpaleja ***@***.***> wrote:
Hello! Is there a function to read a file using the Box file path? E.g. if
the file path is "folder1/folder2/temp_file.csv"
I didn't see one and wrote a quick recursive function to get the file ID
from a file path:
library(data.table)
file_path <- 'folder1/folder2/temp_file.csv'
split_file_path <- strsplit(file_path, "/")[[1]]
dir_id_last = box_getwd()
for (i in seq(1,length(split_file_path))) {
ls_list <- box_ls(dir_id = dir_id_last, limit = 1000, fields = 'name')
dir_id_last <- rbindlist(ls_list)[name == split_file_path[i], id]
}
There is probably a better (more efficient and cleaner) way to create this
function. Do you think this is something that could be implemented?
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#223>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGFKIKWIDYGERPUABKIDIDUQZWUJANCNFSM5J7KVSRA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Hi @rrpaleja In your example below, are you reading the file
|
This use case sounds like it would be suited to {boxrdrive}: https://github.com/r-box/boxrdrive - it is based on the path rather than the folder_id. |
Hello. Loving this package, by the way. I'm looking for the same thing here (specifically, passing a file path to Also, would there be other functions beyond |
Hello, I've created a couple of functions to work around this issue and being able to use directory names and file names in my code:
I start my project defining a project_folder_id, that is saved in the .Renviron file. Then I made as many folders and subfolders as I need. In this example a "data" folder, with 2 subfolders ("dataframes" and "outputs") and inside "outputs" another subfolder is "plots". Like this:
Now I can read files with my other custom function using their name rather than ID:
And write files back to the any of the saved folder IDs:
I hope this is useful for other people. Not sure if this is the best way to do it, any suggestions are welcome. box_subfolder()
box_read_file()
|
Hello! Is there a function to read a file using the Box file path? E.g. if the file path is "folder1/folder2/temp_file.csv"
I didn't see one and wrote a quick recursive function to get the file ID from a file path:
There is probably a better (more efficient and cleaner) way to create this function. Do you think this is something that could be implemented?
Thanks
The text was updated successfully, but these errors were encountered: