Skip to content
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

fread from "clipboard" or "clipboard-128" (on Windows) fails #1292

Open
mbacou opened this issue Aug 26, 2015 · 4 comments
Open

fread from "clipboard" or "clipboard-128" (on Windows) fails #1292

mbacou opened this issue Aug 26, 2015 · 4 comments

Comments

@mbacou
Copy link

mbacou commented Aug 26, 2015

Just noticed (say you "copy" delimited data from a text editor or from MSExcel and want to "paste" as data.table into an R workspace).

# this works
df <- read.delim("clipboard-128")

# this fails
dt <- fread("clipboard-128")
# Error in fread("clipboard-128") : 
#   Unable to open file after 5 attempts (error 3): C:\Users\mbacou\AppData\Local\Temp\RtmpUDARkO\file7643a2c3ff3
# In addition: Warning messages:
#1: running command 'C:\Windows\system32\cmd.exe /c (clipboard-128) > C:\Users\mbacou\AppData\Local\Temp\RtmpUDARkO\file7643a2c3ff3' had status 1 
#2: In shell(paste("(", input, ") > ", tt, sep = "")) :
#   '(clipboard-128) > C:\Users\mbacou\AppData\Local\Temp\RtmpUDARkO\file7643a2c3ff3' execution # failed with error code 1
@kodonnell
Copy link

I'd recommend not doing this, for a few reasons:

  1. it encourages non-reproducible code in projects
  2. I suspect this is a very small use case ...
  3. a trivial solution already exists - just copy into notepad, save as a file, then load it. In most cases, if the file is already in a text editor (or Excel) you can read directly from the file without copy/paste ...

I'm a fan of the 'just because we can do something, doesn't mean we should' motto

@st-pasha
Copy link
Contributor

st-pasha commented Feb 5, 2018

On MacOS it's as simple as fread("pbpaste ").
There are probably similar simple ways of accomplishing this on other platforms too.

@MichaelChirico
Copy link
Member

Could someone on Windows try one of these solutions:

https://stackoverflow.com/questions/17819814/how-can-you-get-the-clipboard-contents-with-a-windows-command

The idea would be to try something like fread("paste ") [NB: the space is required for fread to treat it as a shell command]

Another possibility is that this issue is just #561 in disguise...

@jangorecki
Copy link
Member

Or Get-Clipboard as mentioned in SO. This should be already shipped on recent windowses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants