<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[The Scribblers - Medium]]></title>
        <description><![CDATA[Scribbling Solutions for Your Coding Woes - Medium]]></description>
        <link>https://medium.com/the-scribblers?source=rss----fd4741ff0375---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>The Scribblers - Medium</title>
            <link>https://medium.com/the-scribblers?source=rss----fd4741ff0375---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:20:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/the-scribblers" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Reading & Writing Files with Python Pandas]]></title>
            <link>https://medium.com/the-scribblers/reading-writing-files-with-python-pandas-975ab796feec?source=rss----fd4741ff0375---4</link>
            <guid isPermaLink="false">https://medium.com/p/975ab796feec</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mainak Das]]></dc:creator>
            <pubDate>Tue, 14 Feb 2023 16:13:54 GMT</pubDate>
            <atom:updated>2022-01-07T10:00:43.923Z</atom:updated>
            <content:encoded><![CDATA[<h3>Read and Write Files with Python Pandas</h3><h4>Different ways in which you can input and output data with Python pandas.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZyPFqxMMmh5__8y8aKdj1A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@karishea?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kari Shea</a> on <a href="https://unsplash.com/s/photos/computer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In Python the Pandas library very good library with many effective features that make handling data very easy. Here we will discuss various ways we can input and output data with pandas.</p><p>To install pandas use</p><pre>pip install pandas</pre><ol><li><strong>CSV Files</strong></li></ol><p>.csv file format is one of the most used file formats when working with data science projects. To input/output CSV files in pandas use this.</p><pre>import pandas as pd</pre><pre># reading the <em>file.csv </em>and create df dataframe from it<br>df = pd.read_csv(“file.csv”)</pre><pre>#Perform operations on df Dataframe</pre><pre>#outputs the <em>new_file.csv</em> according to the df<br>df.to_csv(“new_file.csv”) </pre><p><strong>2. Excel Files</strong></p><p>Sometimes you have to work with Excel files in .xlsx format. If you are using an excel file use this.</p><pre>import pandas as pd</pre><pre># reading the <em>file.xlsx  </em>and create df dataframe from it<br>df = pd.read_excel(“file.xlsx”)</pre><pre>#To select a particular sheet you can you this<br>df = pd.read_excel(“file.xlsx”,sheet_name = “Sheet 1”)</pre><pre>#Perform operations on df Dataframe</pre><pre>#outputs the <em>new_file.xlsx</em> according to the df<br>df.to_excel(“new_file.xlsx”) </pre><p><strong>3. HTML Tables</strong></p><p>Getting data from tables on a website when you don&#39;t have any download button is a difficult task. using python you can easily solve this.</p><p>Here, I’ll be getting all the names of the president of India from Wikipedia.</p><pre>import pandas as pd</pre><pre>url = &quot;https://en.wikipedia.org/wiki/List_of_presidents_of_India&quot;</pre><pre>df = pd.read_html(url)</pre><pre>#Print the dataframe<br>#Here df[1] is being used because in df there is a lot more data than we need and in only df[1] the relevant data remains</pre><pre>print(df[1])</pre><pre>#To save the data into csv file<br>df[1].to_csv(&#39;data.csv&#39;)</pre><pre>#To save the data into html file<br>df[1].to_html(&#39;data.html&#39;)</pre><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CFOyGKaW1U2NYwIslkR3Zg.png" /><figcaption>Figure: CSV output for the above code</figcaption></figure><p><strong>4. From Clipboard</strong></p><p>Ever thought of using the copied data from the mouse? using this method you can input a data frame copied in the clipboard.</p><pre>import pandas as pd</pre><pre>#To read a dataframe from clipboard<br>df = pd.read_clipboard()</pre><pre>print(df)</pre><pre>#Copy data to clipboard after performing operations on the df <br>df.to_clipboard(excel=True, index=False)</pre><p><strong>Conclusion</strong></p><p>Here I have only discussed CSV, excel files. Similarly, you can read from various files with formats like XML, JSON, parquet, etc. It is very easy if you follow the pandas documentation <a href="https://pandas.pydata.org/docs/reference/io.html">here</a>. Although pandas have limitations when working with very large datasets but for small to medium scale datasets it is a very powerful library. You can perform various data-related operations with it.</p><p>Thank you for reading till the end. This is my first ever medium post. I hope it helps and you like it!</p><p>Stay safe &amp; stay healthy!</p><p><strong>References:</strong></p><p><a href="https://pandas.pydata.org/docs/reference/io.html#">Input/output - pandas 1.3.5 documentation</a></p><p><em>More content at </em><a href="http://plainenglish.io/"><em>plainenglish.io</em></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><em>free weekly newsletter</em></a><em>. Get exclusive access to writing opportunities and advice in our </em><a href="https://discord.gg/GtDtUAvyhW"><em>community Discord</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=975ab796feec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-scribblers/reading-writing-files-with-python-pandas-975ab796feec">Reading &amp; Writing Files with Python Pandas</a> was originally published in <a href="https://medium.com/the-scribblers">The Scribblers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>