read_clipboard() Read Clipboard data to create DataFrame

import pandas as pd 
df = pd.read_clipboard() # reading from your clipboard 

Visit this Page about DataFrame and copy the first output table using your mouse.
After copying just run the above code.

Output is here ( This depends on what you have copied.)
0  Ravi   1    30       20
1  Raju   2    40       30
2  Alex   3    50       40
read_clipboard(): Read the clipboad data and create DataFrame #B12


sep : By default space is used as separator, we can specify any string or regex delimiter.
engine : Change the default engine if you are getting this error.

Using sep and engine

To copy Functions with Descripitions from the PHP manual here we have to use different delimiter as space is not used here.

Storing data in CSV or Excel file

We can store the output in csv file by using to_csv() or by using Excel file.
import pandas as pd 
df = pd.read_clipboard()
df.to_csv('D:\my_clipboard.csv')# path with file name to store 
Next time by using your mouse select data in any web page ( url ) or excel file or any other Tabular data. Run the above code and take your CSV or Excel file from D drive ( or location of your choice ) .

Creating HTML page by using to_html()

We can use the clipboard data to create HTML tables and save the file as web page or in .html format by using to_html(). Here is the code.
import pandas as pd 

df = pd.read_clipboard()
df.to_html('D:\my_html.html') # change the path to store 
HTML file using Clipboard data
The above code will create my_html.html file at D Drive ( change the location if you want ) . The source code of this file is here
<table border="1" class="dataframe">
    <tr style="text-align: right;">

Python Pandas reading data from Clipboard and create DataFrame by using read_clipboard()


Data input and output from Pandas DataFrame
Pandas to_clipboard() read_excel() to_csv() to_excel()
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 All rights reserved worldwide Privacy Policy Disclaimer