Paste
is a command that, as a side-effect, inserts the contents of the clipboard into the current notebook selection. The return value is always Null
, which means that Paste
cannot be used for our purpose without some awkward notebook manipulation.
There is an undocumented way to access the clipboard: ClipboardNotebook.
NotebookGet[ClipboardNotebook[]]
returns a notebook representation of the clipboard contents. When those contents are plain text, it returns a notebook that is structured like this:
Notebook[{Cell["clipboard text", "Input", options]}, options]
We can recover and import the clipboard text from the first part of the first cell:
ImportString @ NotebookGet[ClipboardNotebook[]][[1, 1, 1]]
(* { {"2014-08-29 03:59:52 ", 27273, " Brown"}
, {"2014-08-29 03:59:53 ", 27276, " Green"}
, {"2014-08-29 03:59:55 ", 27276, " Brown"}
, {"2014-08-29 03:59:57 ", 27303, " Red"}
, {"2014-08-29 03:59:58 ", 27303, " Green"}
, {"2014-08-29 03:59:59 ", 27303, " Brown"}
, {"2014-08-29 04:00:04 ", 27317, " Brown"}
, {"2014-08-29 04:00:07 ", 27331, " Blue"}
, {"2014-08-29 04:00:07 ", 27334, " Blue"}
, {"2014-08-29 04:00:08 ", 27331, " Red"}
, {"2014-08-29 04:00:08 ", 27334, " Cyan"}
}
*)
Bear in mind that the clipboard notebook structure is different for other types of data, such as images, formatted text, or expressions copied from notebooks. Also, as this is an undocumented feature its behaviour could change from release to release (but it has been pretty stable for a long time).