read_clipboard()

Pandas Pandas input output

We can read the copied data from the clip board to Pandas DataFrame.
import pandas as pd 
my_data = pd.read_clipboard() # reading from your clipboard 
print(my_data)

  • read_clipboard() DataFrame using Data from Board

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.)
   NAME  ID  MATH  ENGLISH
0  Ravi   1    30       20
1  Raju   2    40       30
2  Alex   3    50       40

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 

my_data = pd.read_clipboard()
print(my_data)
my_data.to_csv('D:\my_clipboard.csv')
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 

my_data = pd.read_clipboard()
print(my_data)
my_data.to_html('D:\my_html.html')
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">
  <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>
read_csv()

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


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    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 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer