<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kajigga</title>
    <description>The latest articles on DEV Community by Kajigga (@kajigga).</description>
    <link>https://dev.to/kajigga</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F36810%2F07342c6e-7ee0-4d94-adc0-5dd89919bd12.gif</url>
      <title>DEV Community: Kajigga</title>
      <link>https://dev.to/kajigga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kajigga"/>
    <language>en</language>
    <item>
      <title>Using a Proper Text Editor</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Wed, 25 Oct 2017 06:36:56 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/using-a-proper-text-editor-62b</link>
      <guid>https://dev.to/scriptingwithpy/using-a-proper-text-editor-62b</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g8QWZjuu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1506680399198-41eb701968bb%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D9202a2abcfabb6099982c6a30e45c23a" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g8QWZjuu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1506680399198-41eb701968bb%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D9202a2abcfabb6099982c6a30e45c23a" alt="Using a Proper Text Editor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey, you! Yeah, you. Come on over. We need to have a chat. Let's just get a few things out in the open so we can discuss it like adults.&lt;/p&gt;

&lt;p&gt;We need to talk about that text editor you might be using.&lt;/p&gt;

&lt;p&gt;You should never open or edit a Python file with a program such as Microsoft Word, TextEdit (Mac), LibreOffice, Pages, or any other page layout program. Just say no! It won't work. You will get frustrated. Your code won't run. It won't work. (Did I say that already?) There are pretty much...let's see... zero reasons to open code of any kind in such a program. You are only asking for trouble.&lt;sup&gt;&lt;a href="http://scriptingwithpython.com/using-a-proper-code-editor/#fn1" id="fnref1"&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;br&gt;
&lt;a href="http://scriptingwithpython.com/using-a-proper-code-editor/"&gt;Continue Reading -&amp;gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gettingstarted</category>
      <category>python</category>
      <category>editors</category>
    </item>
    <item>
      <title>Recommended Text Editors (2017)</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Wed, 25 Oct 2017 06:34:33 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/recommended-text-editors-2017-bbh</link>
      <guid>https://dev.to/scriptingwithpy/recommended-text-editors-2017-bbh</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RwzP7rKz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1503721827581-14e4c8676769%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D604885f22567a05e6f4196da11cb76b4" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RwzP7rKz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1503721827581-14e4c8676769%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D604885f22567a05e6f4196da11cb76b4" alt="Recommended Text Editors (2017)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking to try out a new text editor? There are literally hundreds of them out in the wild. When it comes to Python, however, only some are useful.&lt;/p&gt;

&lt;p&gt;Here are my 2017 text editor recommendations ranked in from highest to lowest.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://scriptingwithpython.com/recommended-text-editors-2017/"&gt;Continue Reading →&lt;/a&gt;&lt;/p&gt;

</description>
      <category>editors</category>
      <category>gettingstarted</category>
      <category>python</category>
    </item>
    <item>
      <title>I have a Editor Confession to Make</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Wed, 25 Oct 2017 06:30:48 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/i-have-a-editor-confession-to-make-1og</link>
      <guid>https://dev.to/scriptingwithpy/i-have-a-editor-confession-to-make-1og</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ssQWQckz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.unixstickers.com/image/cache/data/stickers/vim/vim.sh-340x340.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ssQWQckz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.unixstickers.com/image/cache/data/stickers/vim/vim.sh-340x340.png" alt="I have a Editor Confession to Make"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have to make a confession. I am a hardcore Vim addict. I start using it 10 years ago when I worked on servers and needed to edit files without a mouse. I spent hours connected to these system and learned to use Vim on the command line. I can't get away from it now. I have so much muscle memory learned with the keyboard shortcuts that I feel handicapped without them in other programs.&lt;/p&gt;

&lt;p&gt;I'm not alone. I'm not the only Vim user out there. &lt;a href="http://scriptingwithpython.com/editor-confession/"&gt;Read More...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>editors</category>
      <category>python</category>
    </item>
    <item>
      <title>Easy Exporting CSV Data with  Python</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Tue, 10 Oct 2017 05:09:05 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/easy-exporting-csv-data-with--python-94h</link>
      <guid>https://dev.to/scriptingwithpy/easy-exporting-csv-data-with--python-94h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N415UR2b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://scriptingwithpython.com/content/images/2017/10/5aa2510fc2dc493a66983ce82d63cce1.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N415UR2b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://scriptingwithpython.com/content/images/2017/10/5aa2510fc2dc493a66983ce82d63cce1.svg" alt="Easy Exporting CSV Data with Python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is a follow-up to &lt;a href="http://scriptingwithpython.com/processing-csv-data-with-python"&gt;Reading CSV Data with Python&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In that article, I described what CSV files are and how to read CSV Data. The flip side to reading data is writing data out to a file. I will summarize again what a CSV file is then go into how to write data in this format.&lt;/p&gt;

&lt;p&gt;CSV files are extremely common. I run into them all the time at work when transferring data. At home, a CSV file is almost always an option when exporting a file from the bank or out of Google Sheets.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is CSV?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;CSV&lt;/strong&gt; = &lt;strong&gt;C&lt;/strong&gt; omma &lt;strong&gt;S&lt;/strong&gt; eparated &lt;strong&gt;V&lt;/strong&gt; alues&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OezDWew6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1485167729757-d0c4103392dc%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3Dab2f7cc21dba01f8e8cb96132d63c7a6" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OezDWew6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1485167729757-d0c4103392dc%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3Dab2f7cc21dba01f8e8cb96132d63c7a6" alt="Easy Exporting CSV Data with Python"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;small&gt;Photo by &lt;a href="https://unsplash.com/@andrewfurlan?utm_source=ghost&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api-credit"&gt;Andrew Furlan&lt;/a&gt; / &lt;a href="https://unsplash.com/?utm_source=ghost&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api-credit"&gt;Unsplash&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;We see them all the time but there seems to be some confusion about what a CSV file really is. When I talk to people about CSV files, I realize that most of us equate them with Microsoft Excel documents. This is probably because Excel is often the default program for opening CSV files.&lt;/p&gt;

&lt;p&gt;Here is the thing. A CSV file is simply a text file. That's it, nothing more. The file extension is usually &lt;code&gt;.csv&lt;/code&gt; but it doesn't have to be. Any file extension is simply a hint to what is contained in the file and doesn't actually determine or control the content type. The &lt;a href="https://en.wikipedia.org/wiki/Comma-separated_values"&gt;Wikipedia Article&lt;/a&gt; about CSV files states that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"CSV" is not a single, well-defined format.&lt;br&gt;&lt;br&gt;
As a result, in practice the term "CSV" might refer to any file that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is plain text using a character set such as ASCII, various Unicode character sets&lt;/li&gt;
&lt;li&gt;consists of records (typically one record per line), with the records divided into fields separated by delimiters&lt;/li&gt;
&lt;li&gt;where every record has the same sequence of fields&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is an example. I have a file called &lt;code&gt;users.csv&lt;/code&gt; sitting on my desktop. In a spreadsheet program (Excel, Google Sheets, LibreOffice, Numbers, etc) this file would look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XIAdfv73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://scriptingwithpython.com/content/images/2017/10/csv_file_1.1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XIAdfv73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://scriptingwithpython.com/content/images/2017/10/csv_file_1.1.png" alt="Easy Exporting CSV Data with Python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those columns and rows are nice and fancy. We think there is something magical going one but it isn't. The contents of this file are really just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_id,first_name,last_name,email
234,Kevin,Crommer,example@example.com
235,Carl,Marx,cmarx@example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can open a CSV file with a plaintext editor to see the true contents. It is very similar to viewing the source of a web page and looking at the underlying HTML.&lt;/p&gt;

&lt;p&gt;A spreadsheet programs reads the CSV file and displays to the user (you and me) a pretty version that makes it easy to see the columns and rows.&lt;/p&gt;

&lt;p&gt;As you can see in my example, A CSV file typically has one row per record. In this case there are 4 columns. The headers of the columns are &lt;code&gt;user_id&lt;/code&gt;, &lt;code&gt;first_name&lt;/code&gt;, &lt;code&gt;last_name&lt;/code&gt; and &lt;code&gt;email&lt;/code&gt;. Records will have one or more columns that are usually, not always, separated by a comma.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enough Review Already, Get to the Writing Data Good Stuff
&lt;/h2&gt;

&lt;p&gt;Ok, ok. Let's learn about how to write CSV data to a file or file-like object.&lt;/p&gt;

&lt;p&gt;There are a few essentials points that you will need to remember when writing out CSV data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do not try to write CSV without a library.
&lt;/h3&gt;

&lt;p&gt;You have better things to do with your time than to figure out how to handle every possible CSV variation. Believe me, I speak from experience. I will admit to wasting days of time before I discovered the built-in (yes built-in) &lt;code&gt;csv&lt;/code&gt; module. Your efforts are better spent getting stuff done.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;csv&lt;/code&gt; module is Awesome
&lt;/h3&gt;

&lt;p&gt;The CSV Module is built into every modern version of Python.&lt;sup&gt;&lt;a href="http://scriptingwithpython.com/easy-exporting-data-as-a-csv-in-python/#fn1" id="fnref1"&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;This module handles all of the intricacies of reading and writing CSV data. It is crazy fast and just works.&lt;/p&gt;

&lt;p&gt;To quote the &lt;a href="https://docs.python.org/3/library/csv.html"&gt;Python Docs&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The csv module implements classes to read and write tabular data in CSV format. It allows programmers to say, “write this data in the format preferred by Excel,” or “read data from this file which was generated by Excel,” without knowing the precise details of the CSV format used by Excel. Programmers can also describe the CSV formats understood by other applications or define their own special-purpose CSV formats.&lt;/p&gt;
&lt;h3&gt;
  
  
  Enough Enough already... Get to An Example
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Okay, okay. Let's start with an example.&lt;/p&gt;

&lt;p&gt;Finish reading this article at &lt;a href="http://scriptingwithpython.com/easy-exporting-data-as-a-csv-in-python/"&gt;http://scriptingwithpython.com/easy-exporting-data-as-a-csv-in-python/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>csv</category>
      <category>scripting</category>
      <category>output</category>
    </item>
    <item>
      <title>Reading CSV Data with Python</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Wed, 04 Oct 2017 19:21:01 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/reading-csv-data-with-python-3o7</link>
      <guid>https://dev.to/scriptingwithpy/reading-csv-data-with-python-3o7</guid>
      <description>

&lt;p&gt;CSV files are extremely common. I run into them all the time at work when transferring data. At home, a CSV file is almost always an option when exporting a file from the bank or out of Google Sheets.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is CSV?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;CSV&lt;/strong&gt; = &lt;strong&gt;C&lt;/strong&gt; omma &lt;strong&gt;S&lt;/strong&gt; eparated &lt;strong&gt;V&lt;/strong&gt; alues&lt;/p&gt;

&lt;p&gt;We see them all the time but there seems to be some confusion about what a CSV file really is. When I talk to people about CSV files, I realize that most of us equate them with Microsoft Excel documents. This is probably because Excel is usually the default program for opening CSV files.&lt;/p&gt;

&lt;p&gt;Here is the thing. A CSV file is simply a text file. That's it, nothing more. The file extension is usually &lt;code&gt;.csv&lt;/code&gt; but it doesn't have to be. Any file extension is simply a hint to what is contained in the file and doesn't actually determine or control the content type. The &lt;a href="https://en.wikipedia.org/wiki/Comma-separated_values"&gt;Wikipedia Article&lt;/a&gt; about CSV files states that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"CSV" is not a single, well-defined format&lt;br&gt;&lt;br&gt;
As a result, in practice the term "CSV" might refer to any file that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is plain text using a character set such as ASCII, various Unicode character sets&lt;/li&gt;
&lt;li&gt;consists of records (typically one record per line), with the records divided into fields separated by delimiters&lt;/li&gt;
&lt;li&gt;where every record has the same sequence of fields&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is an example. I have a file called &lt;code&gt;users.csv&lt;/code&gt; sitting on my desktop. In a spreadsheet program (Excel, Google Sheets, LibreOffice, Numbers, etc) this file would look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XIAdfv73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://scriptingwithpython.com/content/images/2017/10/csv_file_1.1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XIAdfv73--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://scriptingwithpython.com/content/images/2017/10/csv_file_1.1.png" alt="Reading CSV Data with Python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those nice columns and rows are nice and fancy. We think there is something magical going one. However, the contents of this file are really just:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_id,first_name,last_name,email
234,Kevin,Crommer,example@example.com
235,Carl,Marx,cmarx@example.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can open a CSV file with a plaintext editor to see the true contents. It is very similar to viewing the source of a web page and looking at the underlying HTML.&lt;/p&gt;

&lt;p&gt;A spreadsheet programs reads the CSV file and displays to the user (you and me) a pretty version that makes it easy to see the columns and rows.&lt;/p&gt;

&lt;p&gt;As you can see in my example, A CSV file typically has one row per record. In this case there are 4 columns. The headers of the columns are &lt;code&gt;user_id&lt;/code&gt;, &lt;code&gt;first_name&lt;/code&gt;, &lt;code&gt;last_name&lt;/code&gt; and &lt;code&gt;email&lt;/code&gt;. Records will have one or more columns that are usually, not always, separated by a comma.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules for reading CSV Files
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Each row in a CSV file is separated by line breaks.&lt;/li&gt;
&lt;li&gt;Columns are separated by a known character. They are almost always comma-separated but I have seen commas, tabs, pipes (&lt;code&gt;|&lt;/code&gt;) and other wierd stuff.&lt;/li&gt;
&lt;li&gt;If a field contains a comma, it should be surrounded by quotes

&lt;ul&gt;
&lt;li&gt;Example:&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_id,nicknames
987,"joebob,joey,jos"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If a field contains single quotes then it should be surrounded by double quotes

&lt;ul&gt;
&lt;li&gt;Example:&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_id,last_name
987,"O'Neil"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If a field contains double quotes then it should be surrounded by single quotes&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_id,citation
987,'The Man said,"Who goes there?"'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The moral of the story here is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't try to parse CSV files by manually reading a line of the file, splitting by commas into a list.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are way too many ways to get it wrong. Instead, use an existing library to do this part. In Python, the &lt;code&gt;csv&lt;/code&gt; module is essential. It takes care of reading all of these possible things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the builtin Python &lt;code&gt;csv&lt;/code&gt; module
&lt;/h2&gt;

&lt;p&gt;Here are the basic steps for reading a CSV file with the builtin &lt;code&gt;csv&lt;/code&gt; Python module.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a CSV file for reading&lt;/li&gt;
&lt;li&gt;Pass the file handler to the CSV reader&lt;/li&gt;
&lt;li&gt;Iterate through the rows of the file&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will walk through each one in order, showing how I would read my example file from earlier.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Open a csv file for reading
&lt;/h3&gt;

&lt;p&gt;ALl during this example, we are going to use the following CSV data. We will assume it is saved a file called &lt;code&gt;quotes.csv&lt;/code&gt; sitting next to our script.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;quote,speaker
"Don’t you call me a mindless philosopher, you overweight glob of grease!",C-3PO
"We’re doomed.",C-3PO
"But I was going into Tosche Station to pick up some power converters!",Luke Skywalker
"Help me, Obi-Wan Kenobi. You’re my only hope.",Leia Organa
"An elegant weapon for a more civilized age.",Obi-Wan Kenobi
"I find your lack of faith disturbing.",Darth Vader
"Mos Eisley spaceport. You will never find a more wretched hive of scum and villainy.",Obi-Wan Kenobi
"You don’t need to see his identification…These aren’t the droids you’re looking for.",Obi-Wan Kenobi
"It’s the ship that made the Kessel Run in less than 12 parsecs.",Han Solo
"Sorry about the mess.",Han Solo
"She may not look like much, but she’s got it where it counts, kid.",Han Solo
"Governor Tarkin, I should’ve expected to find you holding Vader’s leash. I recognized your foul stench when I was brought on board.",Leia Organa
"I felt a great disturbance in the Force. As if millions of voices suddenly cried out in terror and were suddenly silenced.",Obi-Wan Kenobi
"I suggest a new strategy, Artoo: Let the Wookiee win.",C-3PO
"Hokey religions and ancient weapons are no match for a good blaster at your side, kid.",Han Solo
"That’s no moon. It’s a space station.",Obi-Wan Kenobi
"Who’s the more foolish? The fool or the fool who follows him?",Obi-Wan Kenobi
"Aren’t you a little short for a stormtrooper?",Leia Organa
"Somebody has to save our skins. Into the garbage chute, flyboy!",Leia Organa
"I got a bad feeling about this.",Han Solo
"When I left you I was but the learner. Now I am the master.",Darth Vader
"If you strike me down I shall become more powerful than you can possibly imagine.",Obi-Wan Kenobi
"It’s not impossible. I used to bullseye womp rats in my T-16 back home, they’re not much bigger than 2 meters.",Luke Skywalker
"Cover me, Porkins!",Biggs Darklighter
"Use the Force, Luke.",Obi-Wan Kenobi
"What an incredible smell you've discovered", Han Solo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Opening a file for reading is pretty simple, but I always use the &lt;code&gt;with&lt;/code&gt; command to do it. Doing it this way automatically closes the file. Without it you have to call &lt;code&gt;_file.close()&lt;/code&gt; yourself or you risk loosing data or corrupting the file. Python is forgiving but I just don't like taking the risk. Here is the first part.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

with open('./quotes.csv', 'r') as _filehandler:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Pass the CSV file handler to the Reader
&lt;/h2&gt;

&lt;p&gt;With the filehandler opened, pass it to the csv reader. At this point you have two ways of reading rows. You can use &lt;code&gt;csv.reader&lt;/code&gt; to read the rows as simple lists. This method:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reads every row as a unique object&lt;/li&gt;
&lt;li&gt;has no notion of column headers. The first line of the file is just another row of data&lt;/li&gt;
&lt;li&gt;gives you indexed access to each row

&lt;ul&gt;
&lt;li&gt;i.e. &lt;code&gt;row[0]&lt;/code&gt; or &lt;code&gt;row[1]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The second option, and the one I personally use the most, is &lt;code&gt;csv.DictReader&lt;/code&gt;. This reader:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reads headers from first row&lt;/li&gt;
&lt;li&gt;returns each row as a dictionary where the keys come from first row&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you read it using &lt;code&gt;csv.reader&lt;/code&gt; then the example becomes:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

with open('./quotes.csv', 'r') as _filehandler:
    csv_file_reader = csv.reader(_filehandler)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you read it using &lt;code&gt;csv.DictReader&lt;/code&gt; then we get:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

with open('./quotes.csv', 'r') as _filehandler:
    csv_file_reader = csv.DictReader(_filehandler)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There isn't a huge difference there but you get to decide. I personally prefer using dictionaries that remembering the proper index for the column I am looking for.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Iterate over each row
&lt;/h3&gt;

&lt;p&gt;The final step is to iterate over each row, doing something with it. The pattern &lt;code&gt;for row in csv_file_reader:&lt;/code&gt; is very common. This creates an iterator &lt;sup&gt;&lt;a href="http://scriptingwithpython.com/processing-csv-data-with-python/#fn1" id="fnref1"&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Our example then becomes:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

with open('./example.csv', 'r') as _filehandler:
    csv_file_reader = csv.DictReader(_filehandler)
    for row in csv_file_reader:
        # Do something here
        print(row['quote'])
        print(row['speaker'])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;row&lt;/code&gt; in this script is a dictionary. We can access the quote with &lt;code&gt;row['quote']&lt;/code&gt; and the person who is speaking with &lt;code&gt;row['speaker']&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Et voila! There you go! I suspect that this pattern will become the basis of many scripting projects in the future.&lt;/p&gt;

&lt;p&gt;I recorded a quick video. In it, I show how to create the file in PyCharm and then run it.&lt;/p&gt;




&lt;ol&gt;
&lt;li id="fn1"&gt;
&lt;p&gt;Iterators are pretty awesome when you understand what is happening. They allow for very efficient memory usage with large files, remote data, and cases where you don't know how much information will be processed. In the case of the example given here, it causes the reading to only read the file one row at a time. At no point is the entire CSV file loaded into memory. &lt;a href="http://scriptingwithpython.com/processing-csv-data-with-python/#fnref1"&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;


</description>
      <category>csv</category>
      <category>python</category>
      <category>gettingstarted</category>
    </item>
    <item>
      <title>Create a CSV of Yesterday's Google Calendar Events</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Mon, 25 Sep 2017 09:15:00 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/create-a-csv-of-yesterdays-google-calendar-events-dgm</link>
      <guid>https://dev.to/scriptingwithpy/create-a-csv-of-yesterdays-google-calendar-events-dgm</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2Fgregorian-calendar.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2Fgregorian-calendar.jpg" alt="Create a CSV of Yesterday's Google Calendar Events"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Python is great at processing structured data. There are all sorts of libraries that you can use to parse JSON, CSV, XML, etc. There are libraries to parse calendar (.ics) files as well.&lt;/p&gt;

&lt;p&gt;A few days ago, I needed to pull a CSV report of all of my calendar events from the day before. This task might need to be done more than once. My &lt;a href="http://scriptingwithpython.com/my-lazy-scripter-radar" rel="noopener noreferrer"&gt;scripting radar&lt;/a&gt; immediately picked up a ping and I saw a perfect target for a Python script.&lt;/p&gt;

&lt;p&gt;Sure, I could copy and paste the list from the Agenda view in Google Calendar itself. That could be ok if I only needed to do this once. However, I might do this again and a script gives me &lt;strong&gt;way&lt;/strong&gt; more flexibility and frees me up to do other things.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Task?
&lt;/h2&gt;

&lt;p&gt;Task: Pull a complete list of all calendar events from Google Calendar and save it in a CSV file. The output CVS file must have the following columns.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;title&lt;/th&gt;
&lt;th&gt;start_date&lt;/th&gt;
&lt;th&gt;end_date&lt;/th&gt;
&lt;th&gt;duration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lunch&lt;/td&gt;
&lt;td&gt;2017-09-21 09:00:00-06:00&lt;/td&gt;
&lt;td&gt;2017-09-21 09:55:00-06:00&lt;/td&gt;
&lt;td&gt;55&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Solution to pulling Google Calendar Events to CSV
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pre-requisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python 2.7, preferably Python 3.4 or higher &lt;a href="https://dev.to/scriptingwithpy/my-take-on-python-version-2-vs-3-c70-temp-slug-9579522"&gt;see my take on Python versions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;a good text editor or Python IDE &lt;sup&gt;&lt;a href="http://scriptingwithpython.com/pull-a-list-of-yesterdays-google-calendar-events/#fn1" id="fnref1" rel="noopener noreferrer"&gt;[1]&lt;/a&gt;&lt;/sup&gt;
&lt;/li&gt;
&lt;li&gt;A Google account&lt;/li&gt;
&lt;li&gt;Operating systems:

&lt;ul&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;Mac OS X&lt;/li&gt;
&lt;li&gt;Windows&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Python 2.7, or 3.4 or higher&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;I searched around for a while for a good Python Google Calendar module. I did find several that showed some potential but most seemed a bit dated. I ended up on Google's own developer page &lt;sup&gt;&lt;a href="http://scriptingwithpython.com/pull-a-list-of-yesterdays-google-calendar-events/#fn2" id="fnref2" rel="noopener noreferrer"&gt;[2]&lt;/a&gt;&lt;/sup&gt;. On this page I found a Python example doing much of the process I was looking for. I thought to myself:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Self, there is no reason to recreate something good. Let's take what is good here and modify it to fit our needs."&lt;br&gt;&lt;br&gt;
-- Me&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So that's what I did.&lt;/p&gt;

&lt;p&gt;I modified the code I found on that page to export a CSV&lt;sup&gt;&lt;a href="http://scriptingwithpython.com/pull-a-list-of-yesterdays-google-calendar-events/#fn3" id="fnref3" rel="noopener noreferrer"&gt;[3]&lt;/a&gt;&lt;/sup&gt; file with the values I need. You may also noticed that I adjusted it to nicely pull in more than the 10 events the sample script did. You'll see this later.&lt;/p&gt;

&lt;p&gt;I am mostly satisfied with the end result. It does what it needs to much faster and arguably better than I could manually--and that's the point.&lt;/p&gt;

&lt;p&gt;Much of the instruction on this page comes straight from the Google article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready, Go!
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1 - Setup Environment
&lt;/h3&gt;

&lt;p&gt;The first thing to do is install the Google Calendar Python client library.&lt;/p&gt;

&lt;p&gt;Before doing that, however, you need to setup a virtual environment. I always recommend using a &lt;a href="https://dev.to/scriptingwithpy/setting-up-a-python-virtual-environment-29d-temp-slug-5994947"&gt;virtualenvironment&lt;/a&gt; when installing Python libraries, especially when you're not sure what it does :) .&lt;/p&gt;

&lt;p&gt;If you haven't setup a virtual environment to work on, please do so now. Visit &lt;a href="https://dev.to/scriptingwithpy/setting-up-a-python-virtual-environment-29d-temp-slug-5994947"&gt;virtualenvironment&lt;/a&gt; if you aren't sure how to do this. Go ahead and do this now.&lt;/p&gt;

&lt;p&gt;I'll wait...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1503457917564-4635cba0adf5%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D16a1c8130c4821070326b4385a2a379f" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1503457917564-4635cba0adf5%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D16a1c8130c4821070326b4385a2a379f" alt="Create a CSV of Yesterday's Google Calendar Events"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;small&gt;Photo by &lt;a href="https://unsplash.com/@jaime210?utm_source=ghost&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api-credit" rel="noopener noreferrer"&gt;Jaime Top&lt;/a&gt; / &lt;a href="https://unsplash.com/?utm_source=ghost&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api-credit" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;Make sure you are in your virtualenvironment before doing the next steps.&lt;/p&gt;

&lt;p&gt;In a terminal window, enter the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ pip install --upgrade google-api-python-client dateutil&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should not be prompted for your password to install the package. If you are, then you either didn't setup the virtual environment or you are not working in it. Go back to that page and make sure it is setup correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 - Turn on the Google Calendar API
&lt;/h3&gt;

&lt;p&gt;Follow the "Turn on the Google Calendar API" steps at &lt;a href="https://developers.google.com/google-apps/calendar/quickstart/python" rel="noopener noreferrer"&gt;https://developers.google.com/google-apps/calendar/quickstart/python&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 - Create the Python file &lt;code&gt;pull_from_gcal.py&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Create the Python file to run this script. You may want to create a new project if you are using PyCharm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 - Save the code
&lt;/h3&gt;

&lt;p&gt;Here you can copy/paste the finished code if you want to jump straight to running it. However, you may benefit from a line-by-line (mostly) walk-through to make sure you know what it is doing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6 - Run the script
&lt;/h3&gt;

&lt;p&gt;Run the by right-clicking on the file in PyCharm and select &lt;code&gt;Run 'pull_from_gcal.py'&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2FScreen-Shot-2017-09-24-at-6.33.31-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2FScreen-Shot-2017-09-24-at-6.33.31-PM.png" alt="Create a CSV of Yesterday's Google Calendar Events"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If all goes well, the script will open a browser window where you will be prompted to approve the application. Go ahead and do this. The script will gather the necessary credentials and save them to a local file for future use.&lt;br&gt;&lt;br&gt;
You browser should show a screen like the following if it worked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2FScreen-Shot-2017-09-24-at-9.30.13-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2FScreen-Shot-2017-09-24-at-9.30.13-AM.png" alt="Create a CSV of Yesterday's Google Calendar Events"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the CSV with yesterday's events will be created as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2FScreen-Shot-2017-09-24-at-6.37.31-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fscriptingwithpython.com%2Fcontent%2Fimages%2F2017%2F09%2FScreen-Shot-2017-09-24-at-6.37.31-PM.png" alt="Create a CSV of Yesterday's Google Calendar Events"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap-up, Conclusion, Follow-up
&lt;/h2&gt;

&lt;p&gt;Well, there you go. You now have a script that will save you time if you ever need to do this. Thank you for taking the time to read through and possibly testing this script.&lt;/p&gt;

&lt;p&gt;Here are some potential enhancements to the script you may want to consider making.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pull events from all of your calendars&lt;/li&gt;
&lt;li&gt;Add field with list of attendees&lt;/li&gt;
&lt;li&gt;Add field indicating if the event is a recurring event&lt;/li&gt;
&lt;li&gt;Add field indicating if you created the event or if you were invited&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am working on an ebook with lots of scripting recipes. I plan to include this one with some of these changes. Stay tuned to learn more. I encourage you to subscribe using the form below.&lt;/p&gt;




&lt;ol&gt;
&lt;li id="fn1"&gt;
&lt;p&gt;I Love Pycharm for learning Python. You may see me using vim a lot because I have so much muscle memory with it. PyCharm is so much better for testing and editing code with greate syntax highlighting and code hints. &lt;a href="http://scriptingwithpython.com/pull-a-list-of-yesterdays-google-calendar-events/#fnref1" rel="noopener noreferrer"&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn2"&gt;
&lt;p&gt;https://developers.google.com/google-apps/calendar/quickstart/python &lt;a href="http://scriptingwithpython.com/pull-a-list-of-yesterdays-google-calendar-events/#fnref2" rel="noopener noreferrer"&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn3"&gt;
&lt;p&gt;find more articles on manipulating CSV files at &lt;a href="http://scriptingwithpython.com/pull-a-list-of-yesterdays-google-calendar-events/#fnref3" rel="noopener noreferrer"&gt;↩︎&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>python</category>
      <category>scripting</category>
      <category>csv</category>
      <category>googleapis</category>
    </item>
    <item>
      <title>My Take on Python Version 2 vs 3</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Sat, 23 Sep 2017 20:44:52 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/my-take-on-python-version-2-vs-3-8pl</link>
      <guid>https://dev.to/scriptingwithpy/my-take-on-python-version-2-vs-3-8pl</guid>
      <description>&lt;p&gt;It's a huge point of conversation.&lt;/p&gt;

&lt;p&gt;The internet has been debating the merits of Python 2 vs Python 3 for years now. I am sure the Python foundation would love for everyone to have switched entirely to Python 3 by now. There are reasons to migrate to it and, at least some feel, reasons to stay on 2.7.&lt;/p&gt;

&lt;p&gt;I'll summarize the differences then give my own opinionated take on the whole thing. (Hint: I think everyone should be using Python 3)&lt;/p&gt;

&lt;h2&gt;
  
  
  Python 2.7
&lt;/h2&gt;

&lt;p&gt;Python 2.7.13, the most recent version of the 2.x series, came out way back in 2010.&lt;/p&gt;

&lt;h3&gt;
  
  
  Problems with Python 2.7
&lt;/h3&gt;

&lt;p&gt;No new features have been introduced since that time. The Foundation releases bug fixes but new functionality will only be added to Python 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python 3.x
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Iterators, generators

&lt;ul&gt;
&lt;li&gt;Many lists that would have been in memory lists with 2.7 are generators in Python 3. This make high memory functions much more efficient. There are some disadvantages but I won't go into detail here.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;True UTF8 support - all strings are &lt;em&gt;utf8&lt;/em&gt; by default (Huge win!)&lt;/li&gt;
&lt;li&gt;New features will be added to Python 3&lt;/li&gt;
&lt;li&gt;It is not 7 years since the last release&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Some libraries have not yet been migrated over to support Python 3. This is a huge problem for some people that have code written to rely on these libraries. However, it is my opinion that if the library isn't popular enough to demand a Python 3 version then it may not be necessary. That or &lt;em&gt;get with the game people&lt;/em&gt;.

&lt;ul&gt;
&lt;li&gt;I should note that it has been years since I ran into a library that I &lt;strong&gt;wanted to use&lt;/strong&gt; that didn't work in Python 3.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Opinion
&lt;/h2&gt;

&lt;p&gt;Use Python 3 unless you absolutely have to use Python 2 for some reason. Python 3 is faster and better supported. All of the solutions I share on &lt;a href="https://scriptingwithpython.com"&gt;Scripting With Python&lt;/a&gt; are written with Python 3 first in mind. I may occasionally test them with Python 2 but I won't guarantee it.&lt;/p&gt;

</description>
      <category>python3</category>
      <category>python2</category>
    </item>
    <item>
      <title>5 Tasks That would be fun To Script with Python</title>
      <dc:creator>Kajigga</dc:creator>
      <pubDate>Tue, 19 Sep 2017 19:20:32 +0000</pubDate>
      <link>https://dev.to/scriptingwithpy/5-tasks-that-would-be-fun-to-script-with-python-bi9</link>
      <guid>https://dev.to/scriptingwithpy/5-tasks-that-would-be-fun-to-script-with-python-bi9</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1500110192037-6857e4903521%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D8d76f6a03a0419817f5044064879a6a3" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1500110192037-6857e4903521%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3D8d76f6a03a0419817f5044064879a6a3" alt="5 Tasks That would be fun To Script with Python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is so clichÃ© sounding but the sky really is the limit when it comes to scripting tasks. The feeling of watching the computer do some boring time-consuming task for you is awesome. Sit back and watch it go.&lt;/p&gt;

&lt;p&gt;Listed below are 10 fun tasks that are fun to script and/or automate. I will eventually write detailed posts on each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch a Webpage for changes
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwww.thebluediamondgallery.com%2Fwooden-tile%2Fimages%2Fchanges.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwww.thebluediamondgallery.com%2Fwooden-tile%2Fimages%2Fchanges.jpg" alt="5 Tasks That would be fun To Script with Python"&gt;&lt;/a&gt; Have you ever wanted to know when a new product was released, when a price changes, or when the most recent episode of Parks and Recreation is released? Why go through the effort of doing that yourself? Write a script to download the webpage of your choosing and watch for some value to change, appear, dissapear, whatever. When it changes, take some action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download a random image and set as desktop background image
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/3o85xsGXVuYh8lM3EQ/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3o85xsGXVuYh8lM3EQ/giphy.gif" alt="5 Tasks That would be fun To Script with Python"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Find a website (think Flickr, imgur, Google Photos, etc) that hosts images. Write a script to randomly download one and set it as your desktop background image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download latest News from Website, send via Email
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.pixabay.com%2Fphoto%2F2015%2F12%2F03%2F10%2F12%2Fnews-1074604_640.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.pixabay.com%2Fphoto%2F2015%2F12%2F03%2F10%2F12%2Fnews-1074604_640.jpg" alt="5 Tasks That would be fun To Script with Python"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Many services will send you notifications about their most recent updates. You could create your own script that downloads these and send them to you via email.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create CSV Listing all of your photos
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1499700106800-2f870fc20342%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3Dec96debabb7fff1c5f62662be21b71f3" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1499700106800-2f870fc20342%3Fixlib%3Drb-0.3.5%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26s%3Dec96debabb7fff1c5f62662be21b71f3" alt="5 Tasks That would be fun To Script with Python"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;small&gt;Photo by &lt;a href="https://unsplash.com/@smartphotocourses?utm_source=ghost&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api-credit" rel="noopener noreferrer"&gt;Smart&lt;/a&gt; / &lt;a href="https://unsplash.com/?utm_source=ghost&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api-credit" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/small&gt;&lt;br&gt;&lt;br&gt;
Get a list of your photos in Flickr, Google Photos, etc &lt;em&gt;&amp;lt;fill in service name here&amp;gt;&lt;/em&gt;. If they have an API, great. If not, you could scrape the site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make mass changes to a CSV or Excel file
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.pixabay.com%2Fphoto%2F2013%2F04%2F01%2F09%2F18%2Fspreadsheet-98491_640.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.pixabay.com%2Fphoto%2F2013%2F04%2F01%2F09%2F18%2Fspreadsheet-98491_640.png" alt="5 Tasks That would be fun To Script with Python"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
There are all sorts of things you can do with data saved as a Comma-Separated Values (CSV) or Excel file. A CSV file is just text but it can be tricky to edit. An Excel document is often a bit more than just text but sometimes it isn't. You could open it in a spreadsheet program like Libre Office, OpenOffice, Numbers, Google Sheets, or Microsoft Excel and make the changes, gulp, manually but that is not what were doing here. Automate that task! Do something better with your time.&lt;br&gt;&lt;br&gt;
There will be lots of articles on &lt;a href="http://ScriptingWithPython.com/tags/csv-excel" rel="noopener noreferrer"&gt;ScriptingWithPython.com&lt;/a&gt; that deal with CSV or Excel files as the basis of some scripting or automation task.&lt;/p&gt;

&lt;h1&gt;
  
  
  Have fun
&lt;/h1&gt;

&lt;p&gt;The moral of the story is there are endless ways to script and automated tasks. Have fun! Be productive.&lt;/p&gt;

&lt;p&gt;I recommend subscribing to my &lt;a href="http://scriptingwithpython.com/subscribe" rel="noopener noreferrer"&gt;newsletter&lt;/a&gt;. You will receive updates when new posts are made.&lt;/p&gt;

</description>
      <category>scripting</category>
      <category>tasks</category>
      <category>python</category>
    </item>
  </channel>
</rss>
