Repository navigation
fread from "clipboard" or "clipboard-128" (on Windows) fails #1292
Description
Activity
I'd recommend not doing this, for a few reasons:
- it encourages non-reproducible code in projects
- I suspect this is a very small use case ...
- 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
Reacted by Roman LuštrikOn MacOS it's as simple as
fread("pbpaste ").
There are probably similar simple ways of accomplishing this on other platforms too.Could someone on Windows try one of these solutions:
The idea would be to try something like
fread("paste ")[NB: the space is required forfreadto treat it as a shell command]Another possibility is that this issue is just #561 in disguise...
Reacted by Aman KashyapOr
Get-Clipboardas mentioned in SO. This should be already shipped on recent windowses.It's basically a switch between OS in fread.R:
- Windows use
readClipboard - MacOS use
system(pbpaste) - Linus use either
xcliporxsel
Reacted by Aman Kashyap- Windows use
Hi everyone,
I was looking into this and it seems the Windows failure happens because fread() is trying to execute "clipboard-128" as a shell command, but Windows doesn't recognize it as a valid command.
From the discussion, it looks like this could be handled with a small OS-specific switch in fread.R, as @ben-schwen suggested.
For Windows, I see we could use the built-in
readClipboard()function. But I also noticed in the StackOverflow thread that @MichaelChirico shared, there's another approach using PowerShell'sGet-Clipboardcommand, which could work for modern Windows systems (Win10+). From what I have researched, Get-Clipboard handles different clipboard formats better than readClipboard() , though I'm not entirely sure about the format handling differences between the two.If we go the PowerShell route, we could treat it as a system command with the trailing space (like how @st-pasha works on macOS).
What do you all think? I'd be happy to explore either direction or test both if that helps.
- added a commit that references this issue
on Feb 9, 2026
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).