rdrop2 icon indicating copy to clipboard operation
rdrop2 copied to clipboard

Request: Generic `drop_read` function

Open ClaytonJY opened this issue 8 years ago • 2 comments
trafficstars

I think drop_read_csv defines a really useful pattern: drop_get to a local tempfile, then use read.csv on it. There's a hard limitation on read.csv; if I want to use, say readr::read_csv, I have to re-implement the function changing just that last line (and adding rdrop2::: to the dtoken arg).

I do this a lot, and I suspect it'd be helpful to others to make this easier and enforce good usage.

How about a function drop_read that looks roughly like this?

drop_read <- function(file, function, dest = tempdir(), dtoken = get_dropbox_token(), ...) {

  localfile = paste0("dest, "/", basename(file))

  drop_get(file, local_file = localfile, overwrite = TRUE, dtoken = dtoken)

  function(localfile, ...)  # maybe rlang::as_function?
}

There's no real reason this has to be read-specific, so it could be named something more generic; drop_do? Then drop_read_csv could be a slim wrapper around this new thing.

I'd be happy to file a PR, but I know @karthik is in the middle of API v2 refactoring and I don't want this to get lost in the shuffle.

(p.s. Karthik I'd love to help with that refactoring, just not sure where you're at or what the plan is)

ClaytonJY avatar Jun 26 '17 21:06 ClaytonJY

Thanks Clayton! I like this plan. I will ping you for help on the refactoring shortly.

karthik avatar Jun 26 '17 22:06 karthik

@ClaytonJY Can you please drop me a note at [email protected] to discuss the refactor. 🙏

karthik avatar Jun 27 '17 00:06 karthik