How to copy the output of a node

Hi,

Is there any practical way to copy the output of a node in the clipboard?

Obviously, I can manually select the table with my mouse as shown above but it can be clumsy with large tables and it does not preserve headers.

Is there any magic :magic_wand: shortcut/trick I am missing? :thinking:

Thanks,
Pierre-Louis

Hey,

yes, you are probably looking for CTRL + SHIFT +C (Command + Shift + C for mac) to copy the content + corresponding headers. Shortcuts to select whole table/cells/rows is still in the making and will require a bit more time. With 5.3 we added support for keyboard navigation. So you can now make use of the arrow keys and also:
home → jump to the start of the table
end → jump to the end of the table
page up → jump one page up
page down → jump one page down

Hope this helps already.
Greetings,
Daniel

5 Likes

Hi @DanielBog,

I had not downloaded the 5.3 version yet… but I see it was only released yesterday :sweat_smile:

It took me a few tries to understand to leverage this new feature so, for the ones reading:

  • Select the first cell in your table (RowID=0; Col0)
  • Press “End” to go to the end of your table
  • Then press “Shift” to select the whole

I was selecting the start cell, holding “Shift” pressed and clicking on “End” it was not working. You need to click on “Shift” once you’ve reached the end of the table.

Looking for the next upgrades but it is already a nice improvement :ok_hand:

Thanks!

1 Like

Hi @pierrelouis , depending on your requirements, I have a component that you can attach to a table and it will copy a version of the table to clipboard.

It’s designed primarily for producing copies of tables that can be pasted into forum messages, and I added an option for “confluence compatible” too, which actually means “don’t include apostrophes around items which are necessary for it to work with the forum” ;-).

Of course whether this is useful to you depends on your needs.

There is of course nothing to prevent you from unlinking the component and modifying it if you need it to behave differently :slight_smile:

e.g. the following table has been copied/pasted directly using this component:

Universe_0_0 Universe_0_1 Universe_1_0 Universe_1_1 Cluster Membership
0.8209813015900586 0.6296155438750296 0.5540948874352195 0.06726163524305306 Cluster_0
0.7567290080189123 0.6786912924172006 0.15299493894745675 0.6041119743273782 Cluster_0
0.9071022549618538 0.707461735554638 0.4175543502725003 0.9438535512428249 Cluster_0
0.7362033027133753 0.6909395404644001 0.5542919049228839 0.11346166035247529 Cluster_0
0.7088250095277859 0.4667622647747916 0.049619701976962416 0.9521262359635126 Cluster_0
0.6122630180303962 0.5775828602795174 0.3224076700080458 0.3832919422972719 Cluster_0
0.8268713808863682 0.6275823163096929 0.16229294241015657 0.6962360105026432 Cluster_0
0.7963885804589836 0.6543273842429557 0.8609906852600943 0.6773022420140622 Cluster_0
0.7918927868149498 0.6792125135488081 0.968277987430875 0.49438607689112735 Cluster_0
0.9199024154151341 0.6037444913078251 0.7920616272178277 0.6740569949093143 Cluster_0

and this shows the copied data in “forum” format (top) or “confluence” format (bottom)

If you think this might be useful and have ideas of specific format that you would like copied to clipboard, feel free to make suggestions! :slight_smile:

4 Likes

Can use Command+A/Ctrl+A to select all?

Hi @takbb,

Nice job!

I think the “confluence” format you are referring to is the “Markdown” format :wink:, which is vastly used for software documentation, forums, etc. and it has increased lately as it is the best way to process tables with LLMs: see explanation here.

Your node would probably get much more visibility if you called it “Table to Markdown” (I have searched and didn’t find any published alternative nodes).

I made a small test and if you were able to separate columns with tabs (\t) instead of “|”, we would be able to directly copy-paste it into Excel :star_struck:

Do not hesitate to tag / PM me if you want me to test it!

Hi @pierrelouis , thanks for the positive feedback.

The component was born out of a personal need to upload sample data to the forum, which was painful to write by hand! I added the “confluence” bit when I needed to additionally do similar to include data in confluence pages for work, but you are right that it is more generically “markdown”.

Based on some of your suggestions, I have used it as the basis for a new component, which is a little more flexible, and I can (probably!) easily extend in future if there are other formats requested:

Give it a try and let me know what you think.

Thanks for your links re Markdown. How funny that your mention of copying to clipboard should lead to my component producing “markdown”, which should resonate with your earlier article on linkedin! :smiley:

4 Likes

Hey @eddy0620,

not yet, but we will add it in a future release.

@takbb amazing!

Greetings,
Daniel

3 Likes

Hi @takbb,

You should definitely rename your tool “Table to clipboard (Markdown / Excel)” to ease the search :wink:

The Excel format is almost perfect. To make it work, I need first to paste the output of the node into a notepad before copying and pasting it into Excel. Otherwise, Excel will not detect the carriage returns, as shown below:

image

If possible, you might test alternative carriage returns in your code (/n, /r, /r/n, etc.)

Pierre-Louis

Hi @pierrelouis , thanks for the feedback.

Are you performing a manual copy from the flow variable output?

If you just execute the node, you should be able to paste directly to excel without having to do a manual “copy” anywhere, as the node performs a copy to clipboard directly, provided you have set it to output to clipboard. In my testing that works fine with Excel. That’s with Windows 10, and Office 365 (both web and app)

I included the flow variable output as a means for visualising the output, and of course the intention is that it can also be used for copying/pasting to other apps (e.g. notepad/editors and web pages).

From what I have tried though, whilst this works fine with “simple/standard” apps (e.g. notepad, wordpad, browsers), manually copying/pasting directly from the flow variable display to Excel and other MS Office applications doesn’t seem to work no matter whether I use CR, CRLF or just LF.

Given that what I am placing in the flow variable is EXACTLY what I’m writing to the clipboard (which works with Excel), I can presume that the problem is that the value is being changed either when KNIME renders the flow variable output display, or when that output is then manually copied to the clipboard. Ultimately there appears to be nothing I can do to make that work with Office apps, even though it works fine with other apps, such as Notepad as you have found.

The name of the component… :thinking:… I named it “Table to Markdown (Clipboard)” following your previous suggestion that it might be easier to find if called “Table to Markdown”, but given that the component is primarily designed to write to the clipboard, I felt it should retain Clipboard in the name. Of course it is no longer centred on doing “markdown” so I may yet rethink that.

I imagine the ease with which it is going to be found is very much going to depend on the search terms used. I found it within in a few hits in google, and within the KNIME Hub with both Table to Markdown, and Table to Clipboard. It’s a pity that we can’t give components “aliases” :wink:

That said, my preference would actually be to return my previous" Clipboard Writer" naming, since this better fits with the KNIME naming convention for “writer/sink” nodes.

This component is actually a “data sink” (i.e. it writes to the Clipboard)
e.g.
think of “Excel Writer”, “CSV Writer” vs “Table to JSON” naming

Anyway, while I consider the future naming, let me know how you get on with executing the component and then simply pasting to excel without any intermediate steps. That’s the only mechanism I can currently see working for Excel and other Office apps.

My bad, I had not tested the node this way and, yes, it’s working fine!

image

1 Like

Hi @pierrelouis

phew! :wink:

I’ll investigate further about the flow variable bit when I have some time, as it would be nice to know definitively why that mechanism doesn’t work with Excel, and where the problem is, but glad that the “direct clipboard” method works for you.