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 from clipboard #656
Comments
Here's another workaround that uses clipr and works today: library(tidyverse)
library(clipr)
txt <- "v1,v2\n1.1,1.2\n2.1,2.2"
read_csv(txt)
#> # A tibble: 2 × 2
#> v1 v2
#> <dbl> <dbl>
#> 1 1.1 1.2
#> 2 2.1 2.2
write_clip(txt)
read_csv(paste(read_clip(), collapse = "\n"))
#> # A tibble: 2 × 2
#> v1 v2
#> <dbl> <dbl>
#> 1 1.1 1.2
#> 2 2.1 2.2 |
May I ask why this will not be supported? |
It is supported. Either use @jennybc's example of clipr (which works the same across platforms), or do it with readLines and read_csv(paste(readLines(file("clipboard"))), collapse = "\n")) |
@jimhester That's a great suggestion. But why not comply with base R, so read_csv("clipboard") would internally be treated as read_csv(paste(readLines(file("clipboard"))), collapse = "\n")) ? It think it is far more convenient for users, and should not be too much work for the |
#732 implements clipr::write_clip("a,b,c\n1,2,3")
readr::read_csv("clipboard")
#> # A tibble: 1 x 3
#> a b c
#> <dbl> <dbl> <dbl>
#> 1 1.00 2.00 3.00 |
You sir, are fantastic 👍 |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
I was wondering if reading from a clipboard will be supported in the future? There was an earlier issue which provided a work-around, but it doesn't seem to work anymore.
read_csv can only read from a binary connection while the connection itself only allows for non-binary connections.
Using the base functions, this is quite straightforward.
The text was updated successfully, but these errors were encountered: