How to copy paste a table to a dataframe in polars
read_clipboard
100DaysOfPolars
Author
Joram Mutenge
Published
2025-07-16
As a data professional, you’ll work with many Excel files, and most of them will be poorly formatted. This makes it difficult to read the file into a dataframe. Fortunately, there’s a way to copy only the rows and columns you want and turn them into a dataframe. You can run Polars code that instantly creates a dataframe from the contents of your clipboard. Below is a table copied from an Excel file.
table copied from Excel (actually Numbers)
Paste to dataframe
To paste the table from your clipboard into a dataframe, use the expression pl.read_clipboard. It works like magic. Here’s how to do it: