import pandas as pd
df = pd.read_clipboard() # reading from your clipboard
print(df)
NAME ID MATH ENGLISH
0 Ravi 1 30 20
1 Raju 2 40 30
2 Alex 3 50 40
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. df=pd.read_clipboard(sep='—',engine='python')
import pandas as pd
df = pd.read_clipboard()
print(df)
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 ) .
import pandas as pd
df = pd.read_clipboard()
print(df)
df.to_html('D:\my_html.html') # change the path to store

<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>NAME</th>
<th>ID</th>
<th>MATH</th>
<th>ENGLISH</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>Ravi</td>
<td>1</td>
<td>30</td>
<td>20</td>
</tr>
<tr>
<th>1</th>
<td>Raju</td>
<td>2</td>
<td>40</td>
<td>30</td>
</tr>
<tr>
<th>2</th>
<td>Alex</td>
<td>3</td>
<td>50</td>
<td>40</td>
</tr>
</tbody>
</table>
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.