# Introduction

Occasionally I write posts about Julia tools that are often not commonly known, but are useful in practice. Today I want to talk about the ClipData.jl package.

The post was written under Julia 1.6.3, DataFrames.jl 1.2.2, and ClipData.jl 0.2.1.

# What is ClipData.jl?

The package does one thing and does it well: it allows you to move tabular data between your Julia session and the system clipboard both ways.

The to major use cases are:

1. You have a table in e.g. Google Sheet, you copy it to the system clipboard, and want to interactively ingest it in the Julia session as a table (in my examples I will use DataFrame).
2. You have a DataFrame in your Julia session and you want to copy it to the system clipboard so that you can later paste it in e.g. Google Sheet.

Many data scientists need to do both operations virtually every day, and ClipData.jl comes to the rescue. This package is not only nice, but it has an excellent visuals explaining how things work. Therefore, since they are MIT licensed, I just link to the videos prepared by Peter Deffebach here. Let us get to action.

First you need to know if your data has a header of not. If it has a header we will work with a DataFrame, if it does not we will work with a Matrix.

### Clipping tables

To work with tabular data (having a header) use the cliptable function. To copy data from the system clipboard and store it in a DataFrame called df just write:

df = cliptable() |> DataFrame


On the other hand if you want to copy your df data frame to the system clipboard use:

cliptable(df)


All this is very nicely presented in the following video (in particular notice that column element types are automatically detected):

### Clipping matrices

To work with arrays use the cliparray function. To copy data from system clipboard and store it in a Matrix called mat just write:

mat = cliparray()


On the other hand if you want to copy your mat matrix to system clipboard use:

cliparray(mat)


Here is a video showing the process:

# Conclusions

There are several additional features that ClipData.jl provides (like handling how table cells should be parsed). If you want to know more details please refer to the ClipData.jl homepage.

I am sure you will find this little package quite useful in your data science projects!